Windows SDK笔记(二):在窗口上建立控件
2009-11-10 20:31:08 来源:WEB开发网四、控件与父窗口的协作
1.控件上发生动作时,将向父窗口发送通知消息WM_COMMAND。
WM_COMMAND:
HIWORD(wParam):通知码(notification code)
LOWORD(wParam):控件ID
(HWND)lParam: 控件句柄
除了WM_COMMAND外,每种控件还有可能有其他的通知消息(如WM_DRAWITEM)。
2.父窗口需要控制控件时,向控件发控件消息。
事先应记录下控件句柄,或由ID获取控件句柄
3.备注:
各种控件的通知消码和控制消息可由
MSDN-> Platform SDK-> User Interface Services->Windows User Interface->Controls
查得。
五、控件"类名称"
1.标准控件
BUTTON :按钮
COMBOBOX :复合框
EDIT :编辑
LISTBOX :列表
RichEdit :Rich Edit version 1.0
RICHEDIT_CLASS :Rich Edit version 2.0
SCROLLBAR :滚动条
STATIC :静态
2.外壳附带的公用控件
注:建立前需要用InitCommonControlsEx进行初始化
INITCOMMONCONTROLSEX icex;// Ensure that the common control DLL is loaded.
icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
icex.dwICC = ICC_LISTVIEW_CLASSES;
InitCommonControlsEx(&icex);
HWND hWndListView =CreateWindowEx(0,WC_LISTVIEW, //WC_LISTVIEW不需要加引号
TEXT(""),
WS_CHILD | WS_VISIBLE|WS_BORDER | LVS_ICON | LVS_EDITLABELS | WS_EX_CLIENTEDGE ,
10,
10,
100,
100,
hwnd,
(HMENU)1000, //控件ID
((LPCREATESTRUCT) lParam)->hInstance, //实例句柄
NULL);
}
ANIMATE_CLASS
DATETIMEPICK_CLASS
HOTKEY_CLASS
MONTHCAL_CLASS
PROGRESS_CLASS
REBARCLASSNAME
STATUSCLASSNAME
TOOLBARCLASSNAME
TOOLTIPS_CLASS
TRACKBAR_CLASS
UPDOWN_CLASS
WC_COMBOBOXEX
WC_HEADER
WC_IPADDRESS
WC_LISTVIEW
WC_PAGESCROLLER
WC_TABCONTROL
WC_TREEVIEW
3.特殊窗口
MDIClient :MDI客户区窗口
ComboLBox :The class for the list box contained in a combo box.
DDEMLEvent :Windows NT/2000: The class for DDEML events.
Message :Windows 2000: The class for a message-only window.
#32768 :The class for a menu.
#32769 :The class for the desktop window.
#32770 :The class for a dialog box.
#32771 :The class for the task switch window.
#32772 :Windows NT/2000: The class for icon titles.
更多精彩
赞助商链接