To Establish Control of the Windows SDK Programming
I. Overview
Control is a child window, they are already defined window class, so there is no need to register, do not need to write the message processing function.
WM_CREATE message in the main window, create a child window can be.
Second, the instance
/ / Parameters: window handle, message, message parameters, message parameters
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
/ / Handle messages of interest switch (message)
{
case WM_CREATE:
CreateWindow (TEXT ("BUTTON"), / / ??control class name "
TEXT ("& button (A)"),
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 10, 10, 100, 100, hwnd, (HMENU) 1000,
/ / ??control ID
((LPCREATESTRUCT) lParam) -> hInstance, / / ??instance handle
NULL);
return 0;
case WM_DESTROY:
/ / When the user closes the window, the window is destroyed, the end of the need,
send exit message to exit the message loop PostQuitMessage (0);
return 0;
}
/ / Other messages to the default processing functions provided by the return ::
DefWindowProc (hwnd, message, wParam, lParam);
}
typedef struct tagCREATESTRUCT {
LPVOID lpCreateParams;
HINSTANCE hInstance; / / instance handle HMENU hMenu;
The HWND hwndParent;
int cy;
int cx;
int y;
int x;
LONG style;
The LPCTSTR lpszName;
LPCTSTR lpszClass;
DWORD dwExStyle is;
} CREATESTRUCT, * LPCREATESTRUCT;
Fourth, control and collaboration of the parent windowThird, on the WM_CREATE message
The WM_CREATE lParam parameter will be passed into a set-up information structure pointer (LPCREATESTRUCT). The structure contains some useful information (when the window to create a parameter).
1 action control, will be made to the parent window to send a notification message WM_COMMAND.
WM_COMMAND:
HIWORD (wParam): notification code (Notification code)
LOWORD (wParam): control ID
(HWND) lParam: control handle
Parent window requires different controls to the control of a control message.Addition to WM_COMMAND, each control there may be other notification messages (WM_DRAWITEM).
Advance should be recorded under the control handle, or ID Retrieves the handle
(3) Note:
A notification message code of the various controls and control messages may be
MSDN-> Platform SDK-> User Interface Services-> Windows User Interface-> Controls
INITCOMMONCONTROLSEX icex ;/ / Ensure that the common control DLL is loaded.
icex.dwSize = sizeof (INITCOMMONCONTROLSEX);
icex.dwICC = ICC_LISTVIEW_CLASSES;
InitCommonControlsEx (& icex);
The HWND hWndListView = CreateWindowEx (0, WC_LISTVIEW, / / ??WC_LISTVIEW No quotes
Text ("")
WS_CHILD | WS_VISIBLE | WS_BORDER | LVS_ICON | LVS_EDITLABELS | WS_EX_CLIENTEDGE,
10
10
100,
100,
hwnd,
(HMENU) 1000 / / control ID
((LPCREATESTRUCT) lParam) -> hInstance, / / ??instance handle
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) special windowRichard.
Control class name ”
- Standard controls
Button: button ComboBox: composite frame EDIT: Edit the LISTBOX: list RichEdit: Rich Edit version 1.0
RICHEDIT_CLASS: Rich Edit version 2.0
Scrollbar: scroll bar static: static
2 shell with common controls
Note: the establishment of initialization InitCommonControlsEx
The the MDIClient: MDI client area of ??the window
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.
