Help Center

CWindow.Adding controlsmethod

WindowsmethodCWindow.incdoc-orphan
No implementation located. This member is documented, but the source scan found no matching declaration. It is likely declared in a header this scan does not resolve, or provided by a macro.

Description

To add controls to the window you can use the AddControl method. Alternatively, you can use the API function CreateWindowEx, but then you will have to do scaling by yourself.

Besides the registered class names for the controls, in many cases you can use easier to remember aliases. For example. you can use "STATUSBAR" instead of "MSCTLS_STATUSBAR32".

The AddControl method also provides default styles for all the Windows controls. Therefore, you can save typing unless you need to use different styles.

For example, to add a button you can use

instead of

For a list of predefined class names and styles, see the AddControl method.

If the application is DPI aware, controls created with the AddControl method are scaled according to the DPI setting.

Examples

pWindow.AddControl("Button", pWindow.hWindow, IDCANCEL, "&Close", 350, 250, 75, 23)

pWindow.AddControl("Button", pWindow.hWindow, IDCANCEL, "&Close", 350, 250, 75, 23, _ WS_CHILD OR WS_VISIBLE OR WS_TABSTOP OR BS_PUSHBUTTON OR BS_CENTER OR BS_VCENTER)

Reference

  • Include file CWindow.inc
  • Documented in Windows/Windows GUI/CWindow Class.md
  • Topic: CWindow Class