How to pause a Win32 GUI application and wait for user input?

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi,
Im developing a Win32 GUI application in Visual C++.
I have a function that performs a lot of calculations and that should pause and require a user input a few time during its execution.
The user input is a direct keyboard input, i.e. key presses.
Is there a standard way to do it?
If I insert a loop with a Sleep() function inside, and process user input in the main WndProc function, the application becomes non responsive.
I also tried to put something like this in to the function:
<pre class="prettyprint" style=" while (GetMessage(&msg, hWnd, WM_KEYFIRST, WM_KEYLAST))
{
switch(msg.message)
{
case WM_CHAR:
switch (msg.wParam) {
case 114:
// process input
break;
case 101:
// process input
break;
default:
break;
}
break;
}
} [/code]

but after a few seconds of waiting the program becomes non responsive.
Thanks!
<br/>
<br/>
<br/>
<br/>
<br/>

View the full article
 
Back
Top