int CALLBACK wWinMain (HINSTANCE hInst, HINSTANCE hPrev, LPWSTR lpCmdLine, int iCmdShow) { HWND hwndParent = 0; UCHAR chOption; MSG Message; hInstance = hInst; ParseCommandLine(lpCmdLine, &chOption, &hwndParent); switch(chOption) { case 's': InitSaver(0); break; case 'p': InitSaver(hwndParent); break; case 'c': default: Configure(); return 0; } while (GetMessage(&Message, 0, 0, 0)) DispatchMessage(&Message); return Message.wParam; }
LRESULT WINAPI ScreenSaverProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_CREATE: InitSaver(hWnd); break; case WM_TIMER: OnTimer(hWnd, (UINT)wParam); break; case WM_DESTROY: KillTimer(hWnd, IDT_TIMER); PostQuitMessage(0); return 0; case WM_KEYDOWN: #ifdef DEBUG_MODE // in debug mode, user can exit program by press "ESC" if(VK_ESCAPE == wParam) PostQuitMessage(0); #endif if(IsMagicKey((char)wParam)) return 0; break; } #ifndef DEBUG_MODE return DefScreenSaverProc(hWnd, message, wParam, lParam); #else return DefWindowProc(hWnd, message, wParam, lParam); #endif }
int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmdLine, int iCmdShow) { HWND hwndParent; HWND hwndChild; UINT nPreviousState; int chOption; hInstance = hInst; ParseCommandLine(lpCmdLine, &chOption, &hwndParent); SystemParametersInfo(SPI_SETSCREENSAVERRUNNING, TRUE, &nPreviousState, 0); switch (chOption) { case 's': hwndChild = InitSaver(0); break; case 'p': hwndChild = InitSaver(hwndParent); break; case 'c': default: Configure(); return 0; } MazeMain(hInst, hPrev, lpCmdLine, hwndChild); SystemParametersInfo(SPI_SETSCREENSAVERRUNNING, FALSE, &nPreviousState, 0); return 0; }