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.
Re: MFC get input keys in while loop
What are you doing (or going to do) within this infinite loop?
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.
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?
Re: MFC get input keys in while loop
Quote:
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?
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
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