#include "c_WinApp.h" /* ------------------------------------------------------------------------------------------------------------------ */ /* */ #define WINDOW_CLASS_NAME "WinGUI.Main" c_WinGUI_EventHandlerDef(WM_DESTROY, Main_Destroy) { PostQuitMessage(0); } c_WinGUI_EventHandlerDef(WM_CREATE, Main_Create) { return TRUE; } c_WinGUI_EventMapBegin(WndProc) c_WinGUI_EventMap(WM_DESTROY, Main_Destroy); c_WinGUI_EventMap(WM_CREATE, Main_Create); c_WinGUI_EventMapEnd() static BOOL Register(HINSTANCE hInstance) { WNDCLASS WndClass; WndClass.style = CS_HREDRAW | CS_VREDRAW; WndClass.lpfnWndProc = WndProc; WndClass.cbClsExtra = 0; WndClass.cbWndExtra = 0; WndClass.hInstance = hInstance; WndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION); WndClass.hCursor = LoadCursor(NULL, IDC_ARROW); WndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); WndClass.lpszMenuName = NULL; WndClass.lpszClassName = WINDOW_CLASS_NAME; return RegisterClass(&WndClass); } static HWND Create(HINSTANCE hInstance, int nCmdShow) { HWND hwnd = CreateWindow(WINDOW_CLASS_NAME, WINDOW_CLASS_NAME, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL ); if (hwnd == NULL) { return NULL; } ShowWindow(hwnd, nCmdShow); UpdateWindow(hwnd); return hwnd; } /* ------------------------------------------------------------------------------------------------------------------ */ /* */ c_WinGUI_Main(){ MSG msg; if (!hPrevInstance) { if (!Register(hInstance)) { return FALSE; } } WinApp.hInstance = hInstance; HWND MainHwnd = Create(hInstance, nShowCmd); if (!MainHwnd) { return FALSE; } WinApp.hwnd = MainHwnd; while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return (int)msg.wParam; }