|
Anyone know of a good article on CP on Precompiled Headers? I tried to do a search, but the term is a common one so the number of matches was unhelpful.
|
|
|
|
|
|
Very helpful links!
Thanks!
|
|
|
|
|
Is there a single function to get a window's client rectangle in screen coordinates. I know other ways to do this but I was hoping there was a function to do it.
Ive had a look around but could not find anything. If you know please tell me. Thanks!
|
|
|
|
|
|
|
Thanks. I thought Id used the function before but I must have been mistaken. Thanks anyway!
|
|
|
|
|
Hi everyone,
I have some compilation problems related in using waveInOpen and waveInProc callback function.
Following is snippets of my code:
// function that calls in the waveInOpen
bool WaveIn::Start()
{
// open the wave in device
if(waveInOpen(&hwi, WAVE_MAPPER, &wformat, (DWORD)waveInProc, 0, CALLBACK_FUNCTION) != MMSYSERR_NOERROR) return false;
....
}
// callback function waveInProc
void CALLBACK WaveIn::waveInProc(HWAVEOUT hWaveOut, UINT uMsg, DWORD dwInstance,
DWORD dwParam1, DWORD dwParam2)
{
switch(uMsg)
{
case WIM_DATA:
// ... uses member variables
}
}
The compilation error that I encounter is that waveInOpen parameter 4 (which is the callback function) cannot be casted. I have tried to cast the waveInProc parameter, but to no avail. It compiles alright if I make waveInProc static. However, if I make waveInProc static, it prevents me from modifying the member variables.
Thank you and your solutions are totally appreciated.
Thank you so much and all your comments are appreciated.
|
|
|
|
|
hi..how are you...
i am not sure about waveInOpen and waveInProc...but may i ask for what reason do you want to use this...
i ask this because if it is just to play a wave file there are other ways to do it...
vinnzy
|
|
|
|
|
Vinnzy,
I am actually trying to capture PCM audio using these methods.
Thanks for asking.
|
|
|
|
|
Try this:
//declare global function in the top of .cpp files
LRESULT CALLBACK waveInProc(HWAVEOUT hWaveOut, UINT uMsg, DWORD dwInstance,
DWORD dwParam1, DWORD dwParam2);
WaveIn *wi;
bool WaveIn::Intiate()
{
wi=this;
}
// function that calls in the waveInOpen
bool WaveIn::Start()
{
// open the wave in device
if(waveInOpen(&hwi, WAVE_MAPPER, &wformat, waveInProc, 0, CALLBACK_FUNCTION) != MMSYSERR_NOERROR)
return false;
....
}
//write the funtion of waveInProc
LRESULT CALLBACK waveInProc(HWAVEOUT hWaveOut, UINT uMsg, DWORD dwInstance,
DWORD dwParam1, DWORD dwParam2)
{
//if you need WaveIn class in this function
wi->.....
switch(uMsg)
{
case WIM_DATA:
// ... uses member variables
}
return true
}
All vareables in waveInProc function are global or local in this function.
|
|
|
|
|
Sapto,
Thanks for giving me this solution.
Actually, I have discovered another solution that is using the dwParam1 of the waveInProc which returns a pointer to the WAVEHDR of the finished data block.
Firstly, I assign the dwUser of this data block to 'this'
whPtr->dWUser=this;
Thus, in waveInProc implementation,
...
WAVEHDR* tmpWH = (WAVEHDR*)dwParam1;
WaveIn* tmpWaveIn = (WaveIn*)(tmpWH->dwUser);
...
tmpWaveIn is now, a pointer to the instance of my WaveIn class.
Once again, thanks for your solution!
|
|
|
|
|
In C++, we can declare and initialize the variable i inside the for condition. However, in C, we can't do that, we must declare it first. But almost all the time when I declare a variable, I will initialize it at the same time, this makes re-initializing variable i in for loop unnecessary.
I was wondering would that be considered poor programming style? I've seen this style a lot.
// C code
<br />
int i = 0;<br />
<br />
for( ; i < 5; i++)<br />
{<br />
}<br />
or should I?
<br />
int i = 0;<br />
<br />
for(i = 0; i < 5; i++)<br />
{<br />
}<br />
Thanks
|
|
|
|
|
Alex Ngai wrote:
for( ; i < 5; i++)
{
// code
}
this IS ugly ...
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Thanks for your reply. for( ; i < 5; i++) may seem ulgy to you,
but in fact, I've seen a lot of people use this style. In some
cases, you have no choice, for example:
int foo(int n)
{
for( ; n < 5; n++ )
{
}
}
So, I was wondering when you use for loop in C code, do you
re-initialize the variable i?
-----------------------------
C++ without virtual functions is not OO. Programming with classes but without dynamic binding is called "object based", but not "object oriented".
|
|
|
|
|
Alex Ngai wrote:
In some
cases, you have no choice
No choice?, you could use a while loop rather than a for loop!
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
Always initialise your loop variable at the beginning of a for loop. If it doesn't need to be there, it will be optimised away by the compiler anyway. If you use the first form (not reinitialising it) and you reuse the variable somewhere before the for loop, your for loop is going to be completely screwed.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
the second would be better.....
but if reinitializing is that u consider inappropriate,then tooo i wouldnt go for the first rater i would maybe modify the first a little.....
int i ;
for(i = 0; i < 5; i++)
{
}
"faith, hope, love remain, these three.....; but the greatest of these is love" -1 Corinthians 13:13
|
|
|
|
|
It's very important for me to save big strings in CTreeView object.
I've set limit in my CTreeView object to 500, but it can display only first 250.
How can I change this parameter?
Thanks in advance, Aleksey.
|
|
|
|
|
Try setting the TVS_NOTOOLTIPS style, if it makes no tool tips then it may display the whole thing always.
-- Rocky Dean Pulley
|
|
|
|
|
I mean the max length in CTreeView is about 270 any way. It's a pity!
I need 340 letters!
|
|
|
|
|
my app needs to check if a PC connects to the internet.
(if yes, download files from our web-site.)
is there a function which can checks it very fast?
(currently i use a slow one with timeout)
thx
includeh10
|
|
|
|
|
|
Here are a few ways.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
i teste 2 functions and followings are results of checking time (ms), they are all block-functions
function -------------------- connected ------- disconnected
InternetGetConnectedState -------- 39 ---------- 52,059
InternetCheckConnection -----------451 --------- 104,041
they are too slow
thx
|
|
|
|