#include "windows.h" LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); //Stand WinMain int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { //1. design WindowClass WNDCLASSEX wndClass; LPCTSTR szAppName = L"OFWIN"; wndClass.cbSize = sizeof(WNDCLASSEX); wndClass.style = CS_HREDRAW | CS_VREDRAW; wndClass.lpfnWndProc = WindowProc; wndClass.cbClsExtra = 0; wndClass.cbWndExtra = 0; wndClass.hInstance = hInstance; wndClass.hIcon = LoadIcon(0, IDI_APPLICATION); wndClass.hCursor = LoadCursor(0, IDC_ARROW); wndClass.hbrBackground = static_cast<HBRUSH>(GetStockObject(GRAY_BRUSH)); wndClass.lpszMenuName = 0; wndClass.lpszClassName = szAppName; wndClass.hIconSm = 0; //2. register RegisterClassEx(&wndClass); //3. create Window HWND hWnd = CreateWindow( szAppName, L"A standard WinMain Frame", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, hInstance, 0 ); //4. show Window ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); //5. message routine MSG msg; while (GetMessage(&msg, 0, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return static_cast<int>(msg.wParam); } LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { //case WM_PAINT: //break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd, uMsg, wParam, lParam); } return 0; }
And the 2nd step is drawing out the whole Layout of Chinese chess.