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

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
Windows (Win32) API
API(Application Programming Interface) Win32环境下的所有应用程序都直接或间
接地调用Windows提供得Win32 API函数. 动态链接库 组件对象模型(COM). MSDN的使用
Windows API 调用注意事项
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 );
parameter );
获取消息
BOOL GetMessage(
LPMSG lpMsg, // message information HWND hWnd, // handle to window UINT wMsgFilterMin, // first message UINT wMsgFilterMax // last message );
UINT style; //显示风格 WNDPROC lpfnWndProc; //回调函数 int cbClsExtra; //类额外内存 int cbWndExtra; //窗体额外内存 HINSTANCE hInstance; //实例句柄 HICON hIcon; //图标类型 HCURSOR hCursor; //光标类型 HBRUSH hbrBackground; //背景类型 LPCTSTR lpszMenuName; //菜单类型 LPCTSTR lpszClassName; //类名称 } WNDCLASS, *PWNDCLASS;
消息转换
BOOL TranslateMessage(
CONST MSG *lpMsg // message information
);
消息分发
LRESULT DispatchMessage(
CONST MSG *lpmsg // message information
);
回调函数中消息处理
窗体显示
BOOL ShowWindow(
HWND hWnd, // handle to window int nCmdShow // show state );
窗体更新
BOOL UpdateWindow(
HWND 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
动态链接库查找顺序
应用程序所在的当前目录 Windows目录 Windows系统目录 系统环境变量指示的目录
WindBaidu Nhomakorabeaws编程
WinMain主函数 窗体结构体 注册窗体 构造和显示窗体 消息结构体 回调函数 消息循环 消息处理
窗体结构体
typedef struct _WNDCLASS {
相关文档
最新文档