BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
HWND hWnd;
TCHAR szTitle[] = L"K14Engine"; // The title bar text
TCHAR szWindowClass[] = L"K14Engine"; // The window class name // IMPORTANT:  see if this app is already running.  If so just bring
// it to the front and quit.  All CE apps need to do this. hWnd = FindWindow(szWindowClass, szTitle);
if (hWnd) {
SetForegroundWindow ((HWND) (((DWORD)hWnd) | 0x01));    
return 0;
}  MyRegisterClass(hInstance, szWindowClass); // In order to create a full screen app CreateWindow() needs to be
// called with absolute coordinates that cover the entire display.
// Using CW_USEDEFAULT will not work correctly. hWnd = CreateWindow(szWindowClass, szTitle, WS_VISIBLE,
0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), NULL, NULL, hInstance, NULL); if (!hWnd) {
return FALSE;
} ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);

         SetTimer(hWnd,101,33,NULL);
}LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
short vkKey;
if(hWnd != g_pEngine->GetWndHandle()){
g_pEngine->Dump("Error hWnd value\n");
}
switch (message) {
case WM_CREATE:
                            这里收不到Wm_Create
g_pEngine->Dump("MSG WM_CREATE Received\n"); break;
case WM_TIMER:
                            这里也收不到Wm_timer
                            

解决方案 »

  1.   

    原来我是把SetTimer写在WM_Create里的,但是因为收不到WM_CREATE,所以就写在initinstance里了
      

  2.   

    你的窗口是否能够显示在界面上面?请检查窗口类注册是否正确的指向了 WndProc,以及使用的窗口风格是否不对,如 WS_POPUP 或 WS_OVERLAPPED ...
      

  3.   

    UpdateWindow(...)后,要加上
         while (GetMessage (&msg, NULL, 0, 0))
         {
              TranslateMessage (&msg) ;
              DispatchMessage (&msg) ;
         }
    要不,哪会有消息循环?
      

  4.   

    你的WndProc函数好像没有注册。
      

  5.   

    可是keyDown可以收到阿,我在MyRegisterClass(hInstance, szWindowClass);里注册了WndProc,窗口风格为WS_VISIBLE啊,
      

  6.   

    To  stevenW(无情的雨) 
    我看过别人用api写的程序,updatewindow后面没有取消息循环阿,写在winmain里的
      

  7.   

    To stevenW(无情的雨):
    你理解有问题吧!没有消息循环,你GetMessage干什么?况且要实现你的原意,也应该用PeekMessage,你这样永远只能得到同一个消息!Get是得到,不是取出!
      

  8.   

    To stevenW: It is not the matter of Message Loop, In fact the WM_CREATE is passed and processed during the call to CreateWindow.