You can't just halt the windows message loop by throwing in a while(1) and a sleep.
Everything has to be, get in, do some small amount of work based on the current message and get out again.
So for instance
Code:
BOOL CALLBACK DialogProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static bActivated = FALSE; // a bit of persistent memory for this function
switch (message)
{
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDC_ACTIVATE:
bActivated = TRUE;
break;
}
break;
case WM_TIMER: // maybe WM_KEYDOWN, WM_CHAR, etc etc - RTM to find suitable ones
if ( bActivated && GetAsyncKeyState(vKey) ) {
/* Do Stuff.. */
}
break;
}
return 0;
}
Obviously, in response to some other message, you set the flag to FALSE again.