Win32-SDK常用API函数总结(一).doc

上传人:sk****8 文档编号:3502273 上传时间:2019-06-01 格式:DOC 页数:5 大小:52KB
下载 相关 举报
Win32-SDK常用API函数总结(一).doc_第1页
第1页 / 共5页
Win32-SDK常用API函数总结(一).doc_第2页
第2页 / 共5页
Win32-SDK常用API函数总结(一).doc_第3页
第3页 / 共5页
Win32-SDK常用API函数总结(一).doc_第4页
第4页 / 共5页
Win32-SDK常用API函数总结(一).doc_第5页
第5页 / 共5页
亲,该文档总共5页,全部预览完了,如果喜欢就下载吧!
资源描述

1、几年没用 vc 写代码了。偶尔发现之前整理的一些知识点,删除吧又觉得可惜,就拿出来与大家分享下!若发现有神马错误的地方,请留言,不胜感激!邮箱: Win32 SDK 常用 API 函数总结(一)1、 创建模态对话框:int DialogBox( HINSTANCE hInstance, LPCTSTR lpTemplate, HWND hWndParent, DLGPROC lpDialogFunc );(注:IDD_MAIN 为资源 ID,MainDlgProc 为回调函数,详细参数参考 MSDN)2、 对话框常用消息:(不全面,仅供参考)1) 对话框显示时,会触发一个 WM_INITDIA

2、LOG 消息。LRESULT CALLBACK WindowProc(HWND hwnd, / handle to windowUINT uMsg, / WM_INITDIALOGWPARAM wParam, / handle to control (HWND)LPARAM lParam / initialization parameter);2) 对话框上的滚动条或滑动条控件等被操作时,触发一个 WM_HSCROLL 消息。LRESULT CALLBACK WindowProc(HWND hwnd, / handle to windowUINT uMsg, / WM_HSCROLLWPARA

3、M wParam, / request and positionLPARAM lParam / handle to scroll bar (HWND);3) 对话框上的按钮、组合框、列表框等被操作时,触发出一个 WM_COMMAND 消息。LRESULT CALLBACK WindowProc(HWND hwnd, / handle to windowUINT uMsg, / WM_COMMANDWPARAM wParam, / notification code and identifierLPARAM lParam / handle to control (HWND); wParam Th

4、e high-order word specifies the notification code if the message is from a ontrol. If the message is from an accelerator, this value is 1. If the message is from a menu, this value is zero. The low-order word specifies the identifier of the menu item, control, or accelerator. lParam Handle to the co

5、ntrol sending the message if the message is from a control. Otherwise, this parameter is NULL. 4) 点击最大化或最小化,会触发一个 WM_SIZE 消息。LRESULT CALLBACK WindowProc(HWND hwnd, / handle to windowUINT uMsg, / WM_SIZEWPARAM wParam, / resizing flagLPARAM lParam / client area);wParam Specifies the type of resizing r

6、equested. This parameter can be one of the following values. Value MeaningSIZE_MAXHIDE Message is sent to all pop-up windows when some other window is maximized.SIZE_MAXIMIZED The window has been maximized.SIZE_MAXSHOW Message is sent to all pop-up windows when some other window has been restored to

7、 its former size.SIZE_MINIMIZED The window has been minimized.SIZE_RESTORED The window has been resized, but neither the SIZE_MINIMIZED nor SIZE_MAXIMIZED value applies.lParam The low-order word of lParam specifies the new width of the client area. The high-order word of lParam specifies the new hei

8、ght of the client area. 5) 点击关闭,触发一个 WM_CLOSE:消息LRESULT CALLBACK WindowProc(HWND hwnd, / handle to windowUINT uMsg, / WM_CLOSEWPARAM wParam, / not usedLPARAM lParam / not used);ParametersThis message has no parameters. 3、 常用的 API:(不全面,仅供参考)(1)对话框1) 创建对话框:INT_PTR DialogBox(HINSTANCE hInstance, / hand

9、le to moduleLPCTSTR lpTemplate, / dialog box templateHWND hWndParent, / handle to owner windowDLGPROC lpDialogFunc / dialog box procedure);2) 关闭对话框:BOOL EndDialog(HWND hDlg, / handle to dialog boxINT_PTR nResult / value to return);3) 获取对话框上控件的句柄:HWND GetDlgItem(HWND hDlg, / handle to dialog boxint n

10、IDDlgItem / control identifier);4) 修改对话框的图标:SendMessage( (HWND) hWnd, / handle to destination window WM_SETICON, / message to send(WPARAM) wParam, / icon type(LPARAM) lParam / handle to icon (HICON);(2)组合框1) 为组合框控件增加项:SendMessage( (HWND) hWnd, / handle to destination window CB_ADDSTRING, / message t

11、o send(WPARAM) wParam, / not used; must be zero(LPARAM) lParam / string to add (LPCTSTR); 2) 设置组合框的当前选项:SendMessage( (HWND) hWnd, / handle to destination window CB_SETCURSEL, / message to send(WPARAM) wParam, / item index(LPARAM) lParam / not used; must be zero);(注:建议组合框控件属性去掉 sort ,依次添加组合框的项,那么索引号就

12、为0,1,2,3.,这样便于控制)3) 获得当前选中项的索引值:(返回值即为索引值)SendMessage( (HWND) hWnd, / handle to destination window CB_GETCURSEL, / message to send0, 0 );(3)静态文本1) 设置静态文本:BOOL SetWindowText(HWND hWnd, / handle to window or controlLPCTSTR lpString / title or text);2)获取静态文本:int GetWindowText(HWND hWnd, / handle to win

13、dow or controlLPTSTR lpString, / text bufferint nMaxCount / maximum number of characters to copy);4、 滑动条1)设置范围:SendMessage( (HWND) hWnd, / handle to destination window TBM_SETRANGE, / message to send(WPARAM) TRUE, (LPARAM) MAKELONG(lMinimum, lMaximum) );2) 设置当前值:SendMessage(HWND) hWnd, TBM_SETPOS,(W

14、PARAM) TRUE, (LPARAM) Value); 3) 获得当前值:(返回值为一个 32位数,就是当前位置的值)SendMessage(HWND) hWnd, TBM_GETPOS,0, 0); 5、 窗口1) 使窗口无效(有效):BOOL EnableWindow(HWND hWnd, / handle to windowBOOL bEnable / enable or disable input);6、 常用对话框注:对于保存文件对话框、打开文件对话框、颜色对话框等网上资料较多,不做介绍。1) 文件路径对话框BOOL SHGetPathFromIDList(LPCITEMIDLIST pidl,LPSTR pszPath);注:其他类似的函数,可以参照 MSDN以 SH开头的函数2013.2.21 于雁联

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 实用文档资料库 > 策划方案

Copyright © 2018-2021 Wenke99.com All rights reserved

工信部备案号浙ICP备20026746号-2  

公安局备案号:浙公网安备33038302330469号

本站为C2C交文档易平台,即用户上传的文档直接卖给下载用户,本站只是网络服务中间平台,所有原创文档下载所得归上传人所有,若您发现上传作品侵犯了您的权利,请立刻联系网站客服并提供证据,平台将在3个工作日内予以改正。