• windows SDK创建一个窗体


    #include <windows.h>
    
    /*  Declare Windows procedure  */
    LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
    
    /*  Make the class name into a global variable  */
    char szClassName[ ] = "WindowsApp";
    
    int WINAPI WinMain (HINSTANCE hThisInstance,
                        HINSTANCE hPrevInstance,
                        LPSTR lpszArgument,
                        int nFunsterStil)
    
    {
        HWND hwnd;               /* This is the handle for our window */
        MSG messages;            /* Here messages to the application are saved */
        WNDCLASSEX wincl;        /* Data structure for the windowclass */
    
        /* The Window structure */
        wincl.hInstance = hThisInstance;
        wincl.lpszClassName = szClassName;
        wincl.lpfnWndProc = WindowProcedure;      /* This function is called by windows */
        wincl.style = CS_DBLCLKS;                 /* Catch double-clicks */
        wincl.cbSize = sizeof (WNDCLASSEX);
    
        /* Use default icon and mouse-pointer */
        wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
        wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
        wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
        wincl.lpszMenuName = NULL;                 /* No menu */
        wincl.cbClsExtra = 0;                      /* No extra bytes after the window class */
        wincl.cbWndExtra = 0;                      /* structure or the window instance */
        /* Use Windows's default color as the background of the window */
        wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
    
        /* 注册窗口类 wincl */
        if (!RegisterClassEx (&wincl)) 
            return 0;
    
        /* The class is registered, let's create the program*/
        hwnd = CreateWindowEx (
               0,                   /* Extended possibilites for variation */
               szClassName,         /* 类名 */
               "标题",              /* 标题 */
               WS_OVERLAPPEDWINDOW, /* 窗体样式 */
               CW_USEDEFAULT,       /* 位置x */
               CW_USEDEFAULT,       /* 位置y */
               544,                 /* 宽度 */
               375,                 /* 高度 */
               HWND_DESKTOP,        /* 父窗口句柄 */
               NULL,                /* 无菜单 */
               hThisInstance,       /* 与hThisInstance关联 */
               NULL                 /* 没有窗口创建数据*/
               );
               
        /* 显示窗体 */
        ShowWindow (hwnd, nFunsterStil);
    
        /* Run the message loop. It will run until GetMessage() returns 0 */
        while (GetMessage (&messages, NULL, 0, 0))
        {
            /* Translate virtual-key messages into character messages */
            TranslateMessage(&messages);
            /* Send message to WindowProcedure */
            DispatchMessage(&messages);
        }
    
        /* The program return-value is 0 - The value that PostQuitMessage() gave */
        return messages.wParam;
    }
    
    
    /*  处理接收到消息,系统自动调用  */
    
    LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
        int result;
        switch (message)                  /* handle the messages */
        {
            case WM_DESTROY://程序退出 
                PostQuitMessage (0);       /* send a WM_QUIT to the message queue */
                break;
            default:                      /* for messages that we don't deal with */
                return DefWindowProc (hwnd, message, wParam, lParam);
        }
    
        return 0;
    }
  • 相关阅读:
    tensorflow 镜像
    TDD、BDD、DDD
    Node.js结合Selenium做Web自动化测试
    Selenium 对元素element的操作举例
    Selenium UI 举例 getCssValue
    《测之重器——自动化测试框架搭建指南》
    《Robot Framework自动化测试修炼宝典》道长
    SQLServer中round函数
    SQLServer中对时间和长度的处理
    SQLServer中获取所有数据库名、所有表名、所有字段名的SQL语句
  • 原文地址:https://www.cnblogs.com/dzqdzq/p/3236184.html
Copyright © 2020-2023  润新知