Can somebody tell me why when I run this code, I do not get an WM_KEYDOWN message when I press a key????????
Thanks in advance for any and all helpCode:#include <stdio.h> #include <windows.h> #include <time.h> LRESULT CALLBACK Callback(HWND, UINT, WPARAM, LPARAM); static char *WindowClassName = "MyHack"; int main(void) { WNDCLASS Window; HWND hack; MSG messages; Window.style = CS_GLOBALCLASS; Window.lpfnWndProc = Callback; Window.cbClsExtra = 0; Window.cbWndExtra = 0; Window.hInstance = 0; Window.hIcon = NULL; Window.hCursor = NULL; Window.hbrBackground = NULL; Window.lpszMenuName = NULL; Window.lpszClassName = WindowClassName; if(!RegisterClass(&Window)) { fprintf(stderr, "Could not register the window"); return 1; } hack = CreateWindow(WindowClassName, "", WS_OVERLAPPED | WS_SYSMENU, 0, 0, 0, 0, HWND_DESKTOP, NULL, 0, NULL); if(!hack) { fprintf(stderr, "Could not create the window"); return 1; } while (GetMessage (&messages, NULL, 0, 0)) { printf("got message"); TranslateMessage(&messages); DispatchMessage(&messages); } return messages.wParam; } LRESULT CALLBACK Callback(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) { char temp[256]; switch(message) { case WM_CREATE: printf("\n\nhit create\n\n"); SetTimer(hwnd, 10000, 5000, NULL); break; case WM_TIMER: printf("\n\nhit timer\n\n"); //this is where your stuff would go. //printf("\r%ld", time(NULL)); break; case WM_KEYDOWN: printf("\n\nKeyDown\n\n"); break; case WM_KEYUP: printf("\n\nKey has been pressed\n\n"); break; case WM_DESTROY: PostQuitMessage(0); break; } return DefWindowProc(hwnd, message, wparam, lparam); }
Kendal



LinkBack URL
About LinkBacks


