Here's a bigger picture of some of the code so you can see what I'm doing. If you notice I end up having to handle the keystroke recognition separately from the button click recognition. This won't be an issue when I provide the routines for each button, but I had expected to be able to use PostMessage to the ID_#### in WndProc from within checkButtons. Thanks again for all.
void checkButtons()
{
if (FaceKey == 'N')
NextCommand();
if (FaceKey == 'C')
MessageBox(hwnd, "Cancel button pressed.", "It worked!", MB_OK);
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_CREATE:
hwndNext = CreateWindow("BUTTON", "&Next", WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON, 200, 350, 60, 30, hwnd,(HMENU) ID_NEXT, (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE), NULL);
hwndCancel = CreateWindow("BUTTON", "&Cancel", WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON, 360, 350, 60, 30, hwnd,(HMENU) ID_CANCEL, (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE), NULL);
hwndExit = CreateWindow("BUTTON", "E&xit", WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON, 560, 350, 60, 30, hwnd,(HMENU) ID_EXIT, (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE), NULL);
if (MessageBox(hwnd, "Acceptance statement", "Agreement", MB_YESNO) != IDYES)
PostMessage(hwnd, WM_DESTROY, 0, 0);
break;
case WM_KEYDOWN:
FaceKey = wParam;
ExtKey = lParam;
if (FaceKey == 'X')
PostMessage(hwnd, WM_CLOSE, 0, 0);
checkButtons();
break;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case ID_EXIT:
PostMessage(hwnd, WM_CLOSE, 0, 0);
break;
case ID_NEXT:
MessageBox(hwnd, "Next button pressed.", "It worked!", MB_OK);
break;
case ID_CANCEL:
MessageBox(hwnd, "Cancel button pressed.", "It worked!", MB_OK);
break;
case ID_FILE_EXIT:
PostMessage(hwnd, WM_CLOSE, 0, 0);
break;
}
break;
case WM_CLOSE:
if (MessageBox(hwnd, "Close program?","Exit Application?", MB_YESNO) == IDYES)
DestroyWindow(hwnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
return 0;
}
Take Care,
Ed