当前位置:文档之家› 计算机程序设计语言与方法教学教案

计算机程序设计语言与方法教学教案

HWND hwnd; //消息所属窗体句柄(类似指针) UINT message; //消息本身(宏表示) WPARAM wParam; //消息额外信息(整数) LPARAM lParam; //消息额外信息(整数) DWORD time; //发送时间 POINT pt;//消息发送是光标位置
注册窗体类
ATOM RegisterClass(
CONST WNDCLASS *lpWndClass // class data
);
窗体构造
HWND CreateWindow(
LPCTSTR lpClassName, // registered class name LPCTSTR lpWindowName, // window name DWORD dwStyle, // window style int x, // horizontal position of window int y, // vertical position of window int nWidth, // window width int nHeight, // window height HWND hWndParent, // handle to parent or owner window HMENU hMenu, // menu handle or child identifier HINSTANCE hInstance, // handle to application instance LPVOID lpParam // window-creation data );
动态链接库查找顺序
应用程序所在的当前目录 Windows目录 Windows系统目录 系统环境变量指示的目录
Windows编程
WinMain主函数 窗体结构体 注册窗体 构造和显示窗体 消息结构体 回调函数 消息循环 消息处理
窗体结构体
typedef struct _WNDCLASS {
消息转换
BOOL TranslateMessage(
CONST MSG *lpMsg // message information
);
消息分发
LRESULT DispatchMessage(
CONST MSG *lpmsg // message information
);
回调函数中消息处理
UINT style; //显示风格 WNDPROC lpfnWndProc; //回调函数 int cbClsExtra; //类额外内存 int cbWndExtra; //窗体额外内存 HINSTANCE hInstance; //实例句柄 HICON hIcon; //图标类型 HCURSOR hCursor; //光标类型 HBRUSH hbrBackground; //背景类型 LPCTSTR lpszMenuName; //菜单类型 LPCTSTR lpszClassName; //类名称 } WNDCLASS, *PWNDCLASS;
parameter );
获取消息
BOOL GetMessage(
LPMSG lpMsg, // message information HWND hWnd, // handle to window UINT wMsgFilterMin, // first message UINT wMsgFilterMax // last message );
Windows (Win32) API
API(Application Programming Interface) Win32环境下的所有应用程序都直接或间
接地调用Windows提供得Win32 API函数. 动态链接库 组件对象模型(COM). MSDN的使用
Windows API 调用注意事项
窗体显示
BOOL ShowWindow(
HWND hWnd, // handle to window int nCmdShow // show state );
窗体更新
BOOL UpdateWindow( NhomakorabeaHWND hWnd // handle to window );
消息结构体
typedef struct tagMSG {
} MSG, *PMSG;
回调函数
LRESULT CALLBACK WindowProc(
HWND hwnd, // handle to window UINT uMsg, // message identifier WPARAM wParam, // first message
parameter LPARAM lParam // second message
相关主题