Build Control for Windows SDK Programming

Source: Internet
Author: User
Build Control for Windows SDK Programming

I. Overview

Controls are subwindows, which are defined by the system. Therefore, you do not need to register them or write message processing functions.

When you get the wm_create message in the main window, create a subwindow.

Ii. Instances

// Parameter: Window handle, message, Message Parameter, Message Parameter
Lresult callback wndproc (hwnd, uint message, wparam, lparam)
{
// Process messages of interest
Switch (Message)
{
Case wm_create:
Createwindow (text ("button"), // control "class name"
Text ("button (& )"),
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,ProgramEnd: sends and exits the message to exit the message loop.
Postquitmessage (0 );
Return 0;
}
// Default processing functions provided by the system for other messages
Return: efwindowproc (hwnd, message, wparam, lparam );
}

Iii. wm_create message

The lparam parameter of wm_create will be passed into an information structure pointer (lpcreatestruct) during creation ). The structure contains some useful information (parameters when the window is created ).

Typedef struct tagcreatestruct {
Lpvoid lpcreateparams;
Hinstance; // instance handle
Hmenu;
Hwnd hwndparent;
Int Cy;
Int CX;
Int y;
Int X;
Long style;
Lpctstr lpszname;
Lpctstr lpszclass;
DWORD dwexstyle;
} Createstruct, * lpcreatestruct;

4. Collaboration between controls and parent windows

1. When an action occurs on the control, wm_command will be sent to the parent window.

Wm_command:
Hiword (wparam): Notification code)
Loword (wparam): Control ID
(Hwnd) lparam: control handle

In addition to wm_command, each control may have other notification messages (such as wm_drawitem ).

2. When the parent window needs to control the control, send a control message to the control.

The control handle should be recorded in advance, or the control handle should be obtained by the ID

3. Remarks:

Notifications and control messages of various controls can be

Msdn-> Platform SDK-> User Interface services-> Windows User Interface-> controls

.

V. Control "class name"

1. Standard controls

Button: button
ComboBox: ComboBox
Edit: Edit
ListBox: List
RichEdit: Rich edit Version 1.0
Richedit_class: Rich edit version 2.0
Scrollbar: scroll bar
Static: static

2. Public controls attached to the shell

Note: Before creation, you must use initcommoncontrolsex for initialization.

Initcommoncontrolsex icex; // ensure that the common control DLL is loaded.
Icex. dwsize = sizeof (initcommoncontrolsex );
Icex. dwicc = icc_listview_classes;
Initcommoncontrolsex (& icex );

Hwnd hwndlistview = createmediawex (0, wc_listview, // No quotation marks are required for wc_listview
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 window

Mdiclient: MDI customer zone 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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.