读书笔记:windows程序设计
windows.h是一个最重要的包含文件,囊括若干其他头文件。下面是一些最基本的头文件:WINDEF.H(基本数据类型定义),WINNT.H(支持Unicode的类型定义),WINBASE.H(内核函数),WINUSER.H(用户界面函数),WINGDI.H(图形设备接口函数)
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow);
hInstance is something called a "handle to an instance" or "handle to a module." The operating system uses this value to identify the executable (EXE) when it is loaded in memory. The instance handle is needed for certain Windows functions — for example, to load icons or bitmaps.
The WinMain function is identical to wWinMain, except the command-line arguments are passed as an ANSI string. The Unicode version is preferred. You can use the ANSI WinMain function even if you compile your program as Unicode. To get a Unicode copy of the command-line arguments, call the GetCommandLine function. This function returns all of the arguments in a single string. If you want the arguments as an argv-style array, pass this string to CommandLineToArgvW.
#ifndef UNICODE
#define UNICODE
#endif #include <windows.h>LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR pCmdLine, int nCmdShow)
{// Register the window class.const wchar_t CLASS_NAME[] = L"Sample Window Class";WNDCLASS wc = { };wc.lpfnWndProc = WindowProc;wc.hInstance = hInstance;wc.lpszClassName = CLASS_NAME;RegisterClass(&wc);// Create the window.HWND hwnd = CreateWindowEx(0, // Optional window styles.CLASS_NAME, // Window classL"Learn to Program Windows", // Window textWS_OVERLAPPEDWINDOW, // Window style// Size and positionCW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,NULL, // Parent window NULL, // MenuhInstance, // Instance handleNULL // Additional application data);if (hwnd == NULL){return 0;}ShowWindow(hwnd, nCmdShow);// Run the message loop.MSG msg = { };while (GetMessage(&msg, NULL, 0, 0)){TranslateMessage(&msg);DispatchMessage(&msg);}return 0;
}LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{switch (uMsg){case WM_DESTROY:PostQuitMessage(0);return 0;case WM_PAINT:{PAINTSTRUCT ps;HDC hdc = BeginPaint(hwnd, &ps);FillRect(hdc, &ps.rcPaint, (HBRUSH) (COLOR_WINDOW+1));EndPaint(hwnd, &ps);}return 0;}return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
Notice that the progam does not explicitly call the WindowProc function, even though we said this is where most of the application logic is defined. Windows communicates with your program by passing it a series of messages. The code inside the while loop drives this process. Each time the program calls the DispatchMessage function, it indirectly causes Windows to invoke the WindowProc function, once for each message.
读书笔记:windows程序设计相关推荐
- [读书][笔记]WINDOWS PE权威指南《一》PE的原理和基础 之 第一章 环境搭建及简单破解
文章目录 前言 前期准备 1.1 开发语言MASM32 1.1.1 设置开发环境 下载安装masm 环境变量配置 测试是否配置成功 1.1.2 开发第一个源程序HelloWorld.asm 配置 代码 ...
- 读书笔记-Linux程序设计
文章目录 Linux程序设计 一.入门 二.shell程序设计 三.文件操作 四.linux环境 五.终端 六.使用curses函数库管理基于文本的屏幕 七.数据管理 CSDN 八.MySQL 九.开 ...
- [读书笔记]计算机程序设计艺术第一卷
今天早上送了老婆去上班后,终于把<<计算机程序设计艺术>>第一卷给看完一遍了,应该说过了一遍,因为里面很多证明和数学推理我并没有动手做,所以脑袋里也就只知道第一卷是讲什么和此套 ...
- [读书][笔记]WINDOWS PE权威指南《零》PE基础
参考: https://zhuanlan.zhihu.com/p/47075612 https://docs.microsoft.com/zh-cn/windows/win32/debug/pe-fo ...
- [读书笔记]Windows系统下的docker…
交流群:216672921 最近刚接触了docker,有很多前辈也写了关于docker的搭建和原理的技术博客,在这里我就分享一下我在不同平台搭建docker遇到d问题以及处理方法,在做一切准备工作之前 ...
- c程序设计语言读书笔记,C程序设计语言读书笔记
第一章 导言 第一章带领大家进入了C语言的世界,但是我感觉,如果没有一些基础,要想完全理解这一章的内容,还是有些困难的. 在允许使用某种类型变量值的任何场合,都可以使用该类型的更复杂的表达式.无论文本 ...
- 《The C Programming Language》读书笔记 说明
<The C Programming Language>读书笔记 说明 作为笔记而言,完全是一种自写自看的行为,本来是没有必要写这篇东西的.但是作为一个生活在网络时代的学 生来说,想学好一 ...
- 《Windows核心编程(第5版•英文版)》暨《深入理解.NET(第2版•英文版)》有奖书评/读书笔记征集活动
<Windows核心编程(第5版•英文版)>暨<深入理解.NET(第2版•英文版)>有奖书评/读书笔记征集活动 图灵公司自成立以来,得到了CSDN的很多专家和朋友的帮助.为了感 ...
- 《python 程序设计》读书笔记
<python 程序设计>读书笔记 笔者对于csdn博客的运用还是不太熟练,希望大家能够见谅.以后会不断提升写作的手法.这篇博客是我在学习python程序设计时候的笔记.我也是选择学习了大 ...
- 《Silverlight揭秘》暨《ASP.NET高级程序设计(第2版)》有奖读书笔记征集
<Silverlight揭秘>暨<ASP.NET高级程序设计(第2版)>有奖读书笔记征集 近期图灵公司出版了两本微软技术大作<Silverlight揭秘>和< ...
最新文章
- RasberryPi快速启动(适合首次接触树莓派学习者)
- Android实现炫酷的星空变幻效果
- 目标检测优化2021
- Servlet其他关联类---ServletContext类
- POJ2190 HDU2714 ISBN
- 子目录 makefile make和clean
- python3小游戏源代码_Python入门塔防小游戏,开发步骤和源码,带你轻松学python...
- 蛙人高频交易拆单策略—蛙人高频软件结构及使用说明
- 数列求和再求极限问题
- vue - 禁止input[number]输入 +、-、e 符号,并且只能输入两位小数
- 【论文合集】2022年12月医学影像期刊论文合集
- smb.conf - Samba组件的配置文件
- 简单介绍使用 ssh 连接远程服务器运行图形界面程序
- 【拍摄日志五】拍摄手法,画面构图,光影关系
- C++ Builder和托管C++中属性的使用建议
- 超详细: Type-C接口Macbook笔记本无法充电(时连时断)的傻瓜处理流程
- Python数据结构——对有序表二分查找
- IT企业面试常见逻辑推理题智力题及详解答案(二)
- android 启动页 简书,一、Android App启动图启动界面的简单实现
- STM32——GPIO的CRL、CRH和CNF与MODE的关系
热门文章
- python 三维矩阵乘以二维矩阵_python 二维矩阵转三维矩阵示例
- 属于服务器端运行的程序_服务器端编程Java 引起人们的注意很大程度上始于 applet...
- 电脑上怎么做pdf文件_PDF文件怎么拆分?一看就会!
- 如何删除U盘中的System Volume Information文件夹?
- 类对象等式括号的意义
- HTML5 data-* 自定义属性 ---转载 原文地址:https://www.cnblogs.com/dolphinX/p/3348458.html...
- 数据挖掘概念与技术(韩家伟)阅读笔记5--数据规范化和属性构造
- MySQL中修改root密码的方法
- [整理]flex,datagrid数值列排序
- svg.draw.js draw rectangle 画矩形