Windows core Programming 05-Registration of window classes

Source: Internet
Author: User

Window class

The window class contains data structures for various parameter information of the window. Each window has a window class that creates a window based on the window class. Each window class has a name that must be registered with the system before it can be used.

Categories of window classes

-System window Class

The system already has a defined window class that all applications can use directly

-Application Global Window class

Defined by the user, all modules of the current application can be used easily to generate redundancy

-Application Local window class

Defined by the user, this module can be used in the current application , the local window class can replace the global window class

Registering the System window class

You do not need to register, you can use the window class directly. The system has defined the appropriate name, for example

Press button-button

edit Box-edit

  Windows as long as there are shapes of things are the window large to full screen interface small to the button edit box and so on ...  

Registration of application window classes

Registerclass/registerclassex

ATOM RegisterClass (

CONST wndclass *lpwndclass//type of window class

); After successful registration, a digital ID is returned.

ATOM RegisterClassEx (

CONST wndclassex type of *lpwcx//window class

)

typedef struct {
UINT cbsize; Structure size
The style of the UINT style;//window class
WNDPROC Lpfnwndproc; Window processing functions
The size of the additional data buffer for the Int cbclsextra;//window class
The size of the additional data buffer for the Int cbwndextra;//window
HINSTANCE hinstance; Instance handle of the current module
Hicon hicon;//window icon handle
Hcursor hcursor;//The handle of the mouse
Hbrush hbrbackground;//paint brush handle for drawing window background
LPCTSTR resource ID String for lpszmenuname;//Window menu
LPCTSTR name of the lpszclassname;//window class
Hicon Small icon handle for hiconsm;//window
} wndclassex, *pwndclassex

The registration of the Application Global window class requires adding cs_globalclass such as wndclassexwce{0} in the style of the window class;

Wce.style = ... | Cs_globalclass;

Application Local window class

When registering a window class, do not add cs_globalclass style

Style all Members

Cs_globalclass Application Global Window class

Cs_bytealignclient window client area horizontal position 8 times times the number of alignment

Cs_bytealignwindow the horizontal position of the window 8 times times the alignment

Cs_hredraw window redraw when the window level changes

Cs_vredraw the window redraws when the window changes vertically

CS_CLASSDC that type of window, all have the same drawing (DC) device

Cs_parentdc the type of window, each window is with its own drawing (DC) device

Cs_savebits allows Windows to be saved as graphs (bitmaps), improving the efficiency of drawing windows, but consuming memory resources

Cs_dblclks allow Windows to receive mouse double-click messages

Cs_noclose window does not have a close button

Creating a Window class

CreateWindow

HWND CreateWindow (          lpctstr lpclassname,    lpctstr lpwindowname,    DWORD dwstyle,    int x,    int y,    intint nheight, HWND hwndparent, HMENU HMENU, hinstance hinstance, LPVoid lpparam); 
             

1 The system looks in the application local window class based on the name of the incoming window class, if execution 2 is found, if no execution 3 is found

2 compares the local window class with the HINSTANCE variable that was passed in when the window was created. If you find equality, create and register the same module in the window class, create a window to return. If not equal, proceed to 3. /* Local window classes can only be used by their own processes, and hinstance are created for the same process, this step compares the window classes and hinsance*/

3 in the Application Global window class, if found, executes 4 if no execution 5 is found

4 Using the found window class information, create a window to return

5 Find in System window class, if found Create window returned, otherwise create window failed

CreateWindowEx

CreateWindowEx is an upgraded version of CreateWindow.

HWND CreateWindowEx (          DWORD dwexstyle,    lpctstr lpclassname,    lpctstr lpwindowname,    //window extension style, More arguments than CreateWindow    int x,    intint int nheight, HWND hwndparent, HMENU HMENU, HInstance hinstance, LPVoid lpparam);      

Windows core Programming 05-Registration of window classes

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.