首页 > 系统相关 >windows桌面应用程序框架C语言

windows桌面应用程序框架C语言

时间:2023-04-21 16:14:08浏览次数:35  
标签:windows messages 应用程序 C语言 window UNICODE message NULL wincl

#if defined(UNICODE) && !defined(_UNICODE)
    #define _UNICODE
#elif defined(_UNICODE) && !defined(UNICODE)
    #define UNICODE
#endif

#include <tchar.h>
#include <windows.h>

/*  Declare Windows procedure  */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);

/*  Make the class name into a global variable  */
TCHAR szClassName[ ] = _T("firstapp");

int WINAPI WinMain (HINSTANCE hThisInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR lpszArgument,
                     int nCmdShow)
{
    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 colour as the background of the window */
    wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;

    /* Register the window class, and if it fails quit the program */
    if (!RegisterClassEx (&wincl))
        return 0;

    /* The class is registered, let's create the program*/
    hwnd = CreateWindowEx (
           0,                   /* Extended possibilites for variation */
           szClassName,         /* Classname */
           _T("firstapp"),       /* Title Text */
           WS_OVERLAPPEDWINDOW, /* default window */
           CW_USEDEFAULT,       /* Windows decides the position */
           CW_USEDEFAULT,       /* where the window ends up on the screen */
           544,                 /* The programs width */
           375,                 /* and height in pixels */
           HWND_DESKTOP,        /* The window is a child-window to desktop */
           NULL,                /* No menu */
           hThisInstance,       /* Program Instance handler */
           NULL                 /* No Window Creation data */
           );

    /* Make the window visible on the screen */
    ShowWindow (hwnd, nCmdShow);

    /* 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;
}


/*  This function is called by the Windows function DispatchMessage()  */

LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    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;
}

  

标签:windows,messages,应用程序,C语言,window,UNICODE,message,NULL,wincl
From: https://www.cnblogs.com/roverq/p/17340770.html

相关文章

  • [每天例题]跳石板 C语言
    跳石板题目https://www.nowcoder.com/practice/4284c8f466814870bae7799a07d49ec8?tpId=122&tqId=33674&ru=/exam/oj思路分析以从石板4调到石板24为例:i=4:4(0)——>6(1)i=5:(无)i=6:4(0)——>6(1)——>8(2)  or 4(0)——>6(1)——>9(3)i=7:(无)i=8:4(0)——>6(1)......
  • windows:查看端口占用情况相关命令
    一、通过命令行查找端口被谁占用1、window+R组合键,调出命令窗口2、查看被占用端口对应的PID,输入命令:netstat-ano|findstr端口,回车,记录最后一位数字,即pid3、继续输入tasklist|findstrPID,回车,查看是哪个进程或者程序占用了端口二、通过任务管理器结束进程1、在cmd的命......
  • Windows 离线安装Microsoft Store中的应用
    准备工作这个地址主要是用于下载Microsoft应用的离线安装包https://store.rg-adguard.net/微软应用商店地址https://apps.microsoft.com/store/apps以TranslucentTB为例子https://apps.microsoft.com/store/detail/translucent-tb%E6%B1%89%E5%8C%96/9P16GBJP9L6Z?hl=zh-......
  • Windows 下主程序与动态库(*.dll)释放对方分配的内存操作要点
    同样的代码程序:主程序中释放了一块在动态库(*.dll)或共享库(*.so)中分配的内存,Windows将会出现程序崩溃,而Linux则正常运行。 在linux下,每个进程只有一个heap ,在任何一个共享库模块*.so中通过new或者malloc来分配内存的时候都是从这个唯一的heap中分配的,那......
  • Windows10取消首次开机画面
    在首次设置界面,同时按住Ctrl+shift+F3,然后系统会重启,进入桌面后,系统可能会弹出部署模式选项,直接按窗口右上角“X”退出。XCOPY%windir%\System32\svchost.exe%windir%\System32\oobe\audit.exe/X无法找到或打不开用户和组工具又不能通过cmd激活Administrator和修改口令时,我通......
  • 全志v851s使用GPIO应用程序编写
    1.查看硬件电路图SCH_Schematic1_2022-11-23,查找合适的gpio作为使用pin在这里我们选取GPIOH14(注意目前开发使用这个pin作为触摸屏的pin脚,需要将触摸屏connect断开),因为可以通过排插使用杜邦线将其引出,用于连接别的设备。电路图pdf路径:Yuzukilizard/Hardware/Schematic/SCH_......
  • C语言项目实操-学生管理系统
    本文首发自「慕课网」,想了解更多IT干货内容,程序员圈内热闻,欢迎关注"慕课网"!作者:张磊|慕课网讲师0基础学员在经过C语言基础语法的学习后,需要通过一些实战案例来学习如何将C语言应用到实际工作中,今天我们通过一个学生管理系统案例的开发来提升实际开发能力。1.系统介绍在这里,我们首......
  • 2022山东省职业院校技能大赛物联网赛项(高职组)windows维护
    任务要求:netsh(NetworkShell)是一个windows系统本身提供的功能强大的网络配置命令行工具,请选手在命令提示符窗口中使用命令将netsh的配置信息导出到c:\interface.txt文件中。在服务器计算机进行配置,指定每个shell的最大内存数量为150MB。完成以上任务后请......
  • 2022全国职业院校技能大赛物联网赛项(高职组)windows维护
    任务要求:在控制台命令行窗口中,使用命令查看网络连接以及每一个网络接口设备状态,将命令和执行后的结果截图,另存为B-2-1.jpg。答: 对服务器计算机配置规则:“禁止工作站计算机访问本机任何程序或者端口,暂不启用此规则”,将配置结果界面截图另存为B-2-2.jpg。答: 在控......
  • 2022全国职业院校技能大赛物联网赛项(中职组)windows维护
    任务要求:   在服务器电脑的C盘创建IOT文件夹,赋予Everyone所有者完全控制权限,将配置截图,另存为D-4-1.jpg。答:将系统的虚拟内存设置为自动管理所有驱动器的分页文件大小的配置界面截图,另存为D-4-2.jpg。答:设置密码最长使用期限50天(非域成员),将配置界面截图,另存为D-4-3.j......