zoukankan      html  css  js  c++  java
  • 1st step for Chinese Chess Program- Standard WinMain

    #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.

  • 相关阅读:
    不错的计算机免费电子书网站
    十点提高编程技巧
    delphi 通过TStyleManager设置主题类型
    delphi 简体和繁体字符串转换
    delphi unidac 连接mysql
    Delphi 的字符及字符串 string、AnsiString、WideString、String[n]、ShortString
    delphi format格式
    AnsiString和WideString 区别
    企业级Docker私有仓库部署(https)
    企业级Docker私有仓库之Harbor部署(http)
  • 原文地址:https://www.cnblogs.com/harrysun/p/3194570.html
Copyright © 2011-2022 走看看