Skip to content

Win32 原生编程

从 Windows 最底层的 Win32 API 开始,系统学习窗口管理、消息机制、控件、对话框、资源文件、GDI/GDI+ 绘图、Direct2D、D3D11/D3D12 渲染。

章节列表

基础篇

章节内容文件
0Windows 程序的本质0_ProgrammingGUI_Basic
1消息机制与窗口创建1_ProgrammingGUI_NativeWindows
2常用系统消息2_ProgrammingGUI_NativeWindows_2
3DPI 适配专题3_ProgrammingGUI_WhatAboutDPI

控件篇

章节内容文件
4标准控件(按钮、编辑框等)4_ProgrammingGUI_NativeWindows_Controls
5WM_NOTIFY 通知消息5_ProgrammingGUI_NativeWindows_WM_NOTIFY
6ListView 列表视图控件6_ProgrammingGUI_NativeWindows_ListView
7TreeView 树形视图控件7_ProgrammingGUI_NativeWindows_TreeView
8更多控件(进度条、滚动条等)8_ProgrammingGUI_NativeWindows_MoreControls

对话框篇

章节内容文件
9模态对话框9_ProgrammingGUI_NativeWindows_ModalDialog
10非模态对话框10_ProgrammingGUI_NativeWindows_ModelessDialog
11对话框过程深入11_ProgrammingGUI_NativeWindows_DialogProc

资源篇

章节内容文件
12资源文件完全指南12_ProgrammingGUI_NativeWindows_ResourceFiles
13菜单资源13_ProgrammingGUI_NativeWindows_MenuResource
14图标、光标与位图14_ProgrammingGUI_NativeWindows_IconCursorBitmap
15字符串表与国际化15_ProgrammingGUI_NativeWindows_StringTable
16对话框模板16_ProgrammingGUI_NativeWindows_DialogTemplate
17VS 资源编辑器17_ProgrammingGUI_NativeWindows_VSResourceEditor

工具栏与状态栏

章节内容文件
17.5工具栏与状态栏17_5_ProgrammingGUI_NativeWindows_ToolbarStatusBar

GDI 图形篇

章节内容文件
18GDI 设备上下文(HDC)完全指南18_ProgrammingGUI_NativeWindows_GDI_HDC
19GDI 绘图对象:画笔、画刷、字体19_ProgrammingGUI_NativeWindows_GDI_Objects
20GDI 图形绘制:线条、矩形与多边形20_ProgrammingGUI_NativeWindows_GDI_Shapes
21GDI 文字渲染21_ProgrammingGUI_NativeWindows_GDI_Text
22GDI 位图操作22_ProgrammingGUI_NativeWindows_GDI_Bitmap
23GDI 双缓冲技术23_ProgrammingGUI_NativeWindows_GDI_DoubleBuffer
24GDI Region 与裁切24_ProgrammingGUI_Graphics_GDI_Region
25Alpha 混合与透明效果25_ProgrammingGUI_Graphics_GDI_AlphaBlend

GDI+ 篇

章节内容文件
26GDI+ 架构与抗锯齿渐变26_ProgrammingGUI_Graphics_GdiPlus_Architecture
27坐标变换与矩阵27_ProgrammingGUI_Graphics_GdiPlus_Transform
28图像格式与编解码28_ProgrammingGUI_Graphics_GdiPlus_ImageCodec

Direct2D / DirectWrite 篇

章节内容文件
29Direct2D 架构与资源体系29_ProgrammingGUI_Graphics_Direct2D_Architecture
30Direct2D 几何体系统30_ProgrammingGUI_Graphics_Direct2D_Geometry
31Direct2D 效果与图层31_ProgrammingGUI_Graphics_Direct2D_EffectsLayer
32DirectWrite 高质量文字排版32_ProgrammingGUI_Graphics_DirectWrite_Typography
33Direct2D 与 Win32/GDI 互操作33_ProgrammingGUI_Graphics_Direct2D_GDIInterop

HLSL 着色器篇

章节内容文件
34HLSL 语言基础34_ProgrammingGUI_Graphics_HLSL_Basics
35HLSL 编译与调试35_ProgrammingGUI_Graphics_HLSL_CompileDebug
36Constant Buffer 与数据传递36_ProgrammingGUI_Graphics_HLSL_CBuffer

Direct3D 11 篇

章节内容文件
37D3D11 初始化与 SwapChain37_ProgrammingGUI_Graphics_D3D11_InitSwapChain
38顶点缓冲与输入布局38_ProgrammingGUI_Graphics_D3D11_VertexInput
39纹理与采样器39_ProgrammingGUI_Graphics_D3D11_TextureSampler
40深度缓冲与 3D 变换40_ProgrammingGUI_Graphics_D3D11_Depth3D
41光照模型基础41_ProgrammingGUI_Graphics_D3D11_Lighting
42混合与透明渲染42_ProgrammingGUI_Graphics_D3D11_BlendAlpha

Direct3D 12 篇

章节内容文件
43D3D12 设计哲学43_ProgrammingGUI_Graphics_D3D12_Philosophy
44命令列表、队列与围栏44_ProgrammingGUI_Graphics_D3D12_CmdQueue
45资源与堆管理45_ProgrammingGUI_Graphics_D3D12_ResourceHeap
46描述符堆与根签名46_ProgrammingGUI_Graphics_D3D12_DescRootSig
47D3D12 与 D3D11 互操作47_ProgrammingGUI_Graphics_D3D12_D3D11Interop

自定义控件篇

章节内容文件
48Owner-Draw 控件48_ProgrammingGUI_Graphics_CustomCtrl_OwnerDraw
49完全自绘控件架构49_ProgrammingGUI_Graphics_CustomCtrl_FullCustom
50命中测试与鼠标事件路由50_ProgrammingGUI_Graphics_CustomCtrl_HitTest

OpenGL 篇

章节内容文件
51Win32 嵌入 OpenGL51_ProgrammingGUI_Graphics_OpenGL_Win32

高级消息篇

章节内容文件
52高级输入消息:触控、Raw Input 与窗口管理52_ProgrammingGUI_NativeWindows_AdvancedMessages

Win32 进阶篇

章节内容文件
53子类化与超类化53_ProgrammingGUI_NativeWindows_Subclassing
54Hook 机制54_ProgrammingGUI_NativeWindows_Hook
55系统托盘55_ProgrammingGUI_NativeWindows_SystemTray
56拖放56_ProgrammingGUI_NativeWindows_DragDrop
57定时器57_ProgrammingGUI_NativeWindows_Timer
58加速键表与通用对话框58_ProgrammingGUI_NativeWindows_AcceleratorCommonDialog
59消息机制补充:SendMessage、PostMessage 与跨线程通信59_ProgrammingGUI_NativeWindows_MsgMechanism
60常用系统消息补充:滚轮、命中测试、窗口限制与背景擦除60_ProgrammingGUI_NativeWindows_SystemMessages

配套示例代码

每个章节都配有完整的可运行示例,位于 src/tutorial/native_win32/ 目录:

  • 基础示例:01_hello_world ~ 10_oop_wrapper(10 个渐进式示例)
  • 练习项目:7 个实战练习(点击计数器、随机方块、鼠标追踪器、简单记事本、拖动小球、双缓冲、RichEdit 文本编辑器)

基于 VitePress 构建