|
-
July 3rd, 2012, 07:43 PM
#1
MFC get input keys in while loop
I don't know how to bypass how MFC handles messages but I need to read input character keys while being in a while loop. An example is posted below;
Code:
runmode=1;
//get input keys from keyboard some how
while(runmode==1)
{
wait(50);
//get input keys
}
break;
While this is may be an infinite loop it shows that I need to get input keys while the while loop is operating, so CRichEditCtrl::OnChar simply won't work because the message handle doesn't process until after the code completes execution.
-
July 4th, 2012, 02:55 AM
#2
Re: MFC get input keys in while loop
What are you doing (or going to do) within this infinite loop?
Victor Nijegorodov
-
July 5th, 2012, 01:52 PM
#3
Re: MFC get input keys in while loop
I'm going to read key strokes and send the key strokes to a microcontroller and have the microcontroller process them and send back commands that may end the infinite loop.
-
July 5th, 2012, 02:03 PM
#4
Re: MFC get input keys in while loop
But why the loop? Why bypass normal Windows message processing? Why not just respond to key events as you get them?
-
July 5th, 2012, 04:20 PM
#5
Re: MFC get input keys in while loop
 Originally Posted by printz0r
I'm going to read key strokes and send the key strokes to a microcontroller and have the microcontroller process them and send back commands that may end the infinite loop.
And what does it have to do with the CRichEditCtrl?
Victor Nijegorodov
-
July 6th, 2012, 05:49 PM
#6
Re: MFC get input keys in while loop
RichEditCtrl displays values that the microcontroller outputs. The loop is important because there are various modes the microcontroller is in. Sometimes it should get values, othertimes it shouldn't
-
July 7th, 2012, 03:38 AM
#7
Re: MFC get input keys in while loop
You should avoid implementing such type of loops (like infinite)in the main GUI thread.
Create a worker thread and move this infinite loop to get values from the microcontrollers in this worker thread.
Read about Using Worker Threads
Victor Nijegorodov
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|