How to remember the wndclass (Ex) structure and createwindow (Ex) Parameters

Source: Internet
Author: User

Wndclass (Ex) structure and createwindow (Ex) function are the first features of Windows graphic programming. Although the IDE can automatically generate a template or provide smart prompts, I still like to write it by myself. I like to grasp all the details from the underlying layer. Windows programming is actually very simple, and the function name is also relatively intuitive, that is, there are some large structures or functions that are hard to remember (very few), for example, direct3d needs to use d3dpresent_parameters, create the logfont structure of the font. However, I am familiar with it when I use it more often, and these structures generally have some rules.

In fact, the wndclass structure is quite easy to remember. There are 10 members in total, which can be referred to as 1, 2, 3, and 4, respectively:

1 style;

Two CB (count byte), cbclsextra and cbwndextra;

3 LP (long pointer), lpfnwndproc, lpszclassname, lpszmenuname;

4 H (handle): hbrbackground, hicon, hcursor, hinstance;

Later, the wndclassex structure was two more than the original one: cbsize (structure size) and hiconsm (small icon ). Concerning small icons, Petzold said in his classic book that wndclassex is very strange, because the added two members are not very useful. The ICO file can store two icons, one for a while and one for a while. In Windows, you can select an appropriate icon as needed. However, you need to add another hiconsm, which requires creating additional files and specifying them manually, he suggested that wndclass should be used directly instead of this ex. As mentioned in the msdn document, if you do not need to specify a small icon, use the original one without any impact.

Createwindow also has many parameters. I generally write them as four lines.

1. lpctstrLpclassname, LpctstrLpwindowname, // This row is the window class name, window title: Specifies the window and window title you want to create

2. DWORDDwstyle, // This row is the style of the window: Details
3. intX, IntY, IntNwidth, IntNheight, // This row is the dimension of the window, or geometry, that is, the location and size: Needless to say
4. hwndHwndparent, HmenuHmenu, HinstanceHinstance, LpvoidLpparam// This row contains the parent window handle, menu handle (or control ID), instance handle, and additional parameters: a bunch of handles

Createmediawex only adds the DWORD dwexstyle parameter at the beginning, but this extended style is especially important because many types of Windows can only be created through this parameter, for example, transparent window, tool window, top window, multi-Document Interface (MDI) window, etc., usually used to play games extended style (full screen window ). Therefore, we recommend that you use the ex version when creating the window. Generally, you can pass the first parameter 0.

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.