WndProc(全称 Window Procedure)指 Windows 图形界面编程(Win32 API)中的“窗口过程/窗口消息处理函数”,用于接收并处理发送给某个窗口的消息(如鼠标点击、键盘输入、重绘、关闭等)。
/ˈwɪnd.prɑːk/
A WndProc handles messages like clicks and keystrokes.
WndProc 会处理诸如鼠标点击和键盘输入之类的消息。
In a Win32 app, the window’s WndProc typically switches on message IDs (e.g., WM_PAINT, WM_DESTROY) and calls DefWindowProc for anything it doesn’t handle.
在 Win32 程序中,窗口的 WndProc 通常会根据消息编号(如 WM_PAINT、WM_DESTROY)进行分发,对未处理的消息则调用 DefWindowProc 交给系统默认处理。
WndProc 是 Windows 编程领域的缩写写法:Wnd(Window 的缩写,意为“窗口”)+ Proc(Procedure 的缩写,意为“过程/处理函数”)。它源自早期 WinAPI 的命名习惯,强调“用于处理窗口消息的过程函数”。