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
{
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
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
要不,哪会有消息循环?
我看过别人用api写的程序,updatewindow后面没有取消息循环阿,写在winmain里的
你理解有问题吧!没有消息循环,你GetMessage干什么?况且要实现你的原意,也应该用PeekMessage,你这样永远只能得到同一个消息!Get是得到,不是取出!