Click here to Skip to main content
15,891,033 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Determing the area of a set of rectangles Pin
Filousov5-Mar-04 13:36
Filousov5-Mar-04 13:36 
GeneralBuffer Overflow's Pin
Frank Deo3-Mar-04 13:13
Frank Deo3-Mar-04 13:13 
GeneralRe: Buffer Overflow's Pin
Prakash Nadar3-Mar-04 13:35
Prakash Nadar3-Mar-04 13:35 
GeneralRe: Buffer Overflow's Pin
Steve S4-Mar-04 6:13
Steve S4-Mar-04 6:13 
GeneralRe: Buffer Overflow's Pin
Mike Dimmick4-Mar-04 6:29
Mike Dimmick4-Mar-04 6:29 
GeneralRe: Buffer Overflow's Pin
Frank Deo4-Mar-04 11:37
Frank Deo4-Mar-04 11:37 
GeneralAVI FIles Pin
Anonymous3-Mar-04 12:20
Anonymous3-Mar-04 12:20 
GeneralProcessing messages Pin
ffazly3-Mar-04 11:48
ffazly3-Mar-04 11:48 
Hi. I have a question with regards to processing windows messages. I have a block of pseudo code below:

while (TRUE)<br />
      {    <br />
           //play a tone<br />
        <br />
	   // get user response (keyboard input)<br />
           responded = get_response() ;<br />
<br />
	   // if no response, increase by 5 dB, go to "play tone"<br />
	   if (responded == FALSE)<br />
			<br />
	   // else process the response<br />
	   else<br />
	   {<br />
	      //process response 	<br />
	       threshold_found = process_success();<br />
			<br />
	      //if threshold not found, decrease by 10 dB, go to "play tone"<br />
		if (threshold_found == FALSE)<br />
				<br />
		// else record threshold and go to next frequency, <br />
		// restore familiarization_level, go to "play tone"<br />
		else<br />
		{<br />
		     record_threshold() ;<br />
				<br />
		     // restart the test at the next frequency			<br />
		     restart = restartTest() ;<br />
		     // if finished with test get out of while loop		<br />
		     if(restart == FALSE)<br />
			break ;		<br />
		}<br />
	    }<br />
	}


I want to be able to receive keyboard messages while this while loop is executing and also to be able to detect any other messages like button clicks, etc...

I've tried to use PeekMessage :

while(iCheck == BST_CHECKED)<br />
			{	<br />
				gen_sound(0, 0.02, 1, current_frequency, duration) ; // play tone<br />
<br />
				while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))<br />
				{<br />
					TranslateMessage (&msg) ;<br />
					DispatchMessage (&msg) ;<br />
<br />
					if(msg.message == WM_COMMAND)<br />
					{<br />
						if(msg.wParam == IDC_START) //check if start button has been pressed<br />
							iCheck = (int) SendMessage(hCtrl, BM_GETCHECK, 0, 0) ;<br />
<br />
						break ;<br />
					}<br />
														<br />
				}<br />
			}


but I can't seem to get it to retrieve any messages. I've implemented this code in a callback function that is subclassed from the main window so that it can intercept the window messages. Any insight on what I maybe doing wrong or any kind of advice on the matter would be greatly appreciated.

Fazly
GeneralRe: Processing messages Pin
rrrado4-Mar-04 6:28
rrrado4-Mar-04 6:28 
GeneralDeprecated files in \MS Visual Studio\VC98 Pin
john john mackey3-Mar-04 11:13
john john mackey3-Mar-04 11:13 
GeneralMFC dialog member sharing? (code included) Pin
Christophocles3-Mar-04 11:12
sussChristophocles3-Mar-04 11:12 
GeneralRe: MFC dialog member sharing? (code included) Pin
BlackDice4-Mar-04 5:10
BlackDice4-Mar-04 5:10 
GeneralRe: MFC dialog member sharing? (code included) Pin
Christophocles4-Mar-04 5:44
sussChristophocles4-Mar-04 5:44 
GeneralRe: MFC dialog member sharing? (code included) Pin
monrobot134-Mar-04 5:39
monrobot134-Mar-04 5:39 
GeneralRe: MFC dialog member sharing? (code included) Pin
Christophocles4-Mar-04 5:49
sussChristophocles4-Mar-04 5:49 
GeneralRe: MFC dialog member sharing? (code included) Pin
BlackDice4-Mar-04 6:07
BlackDice4-Mar-04 6:07 
GeneralRe: MFC dialog member sharing? (code included) Pin
Christophocles4-Mar-04 7:06
sussChristophocles4-Mar-04 7:06 
GeneralRe: MFC dialog member sharing? (code included) Pin
BlackDice4-Mar-04 8:23
BlackDice4-Mar-04 8:23 
GeneralRe: MFC dialog member sharing? (code included) Pin
Christophocles4-Mar-04 9:14
sussChristophocles4-Mar-04 9:14 
GeneralRe: MFC dialog member sharing? (code included) Pin
BlackDice4-Mar-04 9:30
BlackDice4-Mar-04 9:30 
GeneralRe: MFC dialog member sharing? (code included) Pin
Christophocles4-Mar-04 10:27
sussChristophocles4-Mar-04 10:27 
GeneralRe: MFC dialog member sharing? (code included) Pin
BlackDice5-Mar-04 3:49
BlackDice5-Mar-04 3:49 
GeneralRe: MFC dialog member sharing? (or, My Marathon Ineptitude) Pin
Christophocles5-Mar-04 4:41
sussChristophocles5-Mar-04 4:41 
GeneralRe: MFC dialog member sharing? (or My Enduring Ineptitude) Pin
Christophocles5-Mar-04 6:25
sussChristophocles5-Mar-04 6:25 
GeneralRe: MFC dialog member sharing? (or My Enduring Ineptitude) Pin
BlackDice5-Mar-04 10:43
BlackDice5-Mar-04 10:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.