CWnd::CreateEx

Syntax

Protected:
BOOL CreateEx( DWORD
dwExStyle, const char FAR* lpClassName,
const char FAR*
lpWindowName, DWORD dwStyle, int x, int y, int nWidth,
int
nHeight, HWND hwndParent, HMENU nIDorHMenu );

Parameters

dwExStyle

Specifies the extended style of the CWnd being created. It may be one of the following values:

Style Meaning

WS_EX_DLGMODALFRAME Designates a window with a double border that may optionally be created with a title bar by specifying the WS_CAPTION style flag in dwStyle.
WS_EX_NOPARENTNOTIFY Specifies that a child window created with this style will not send the WM_PARENTNOTIFY message to its parent window when the child window is created or destroyed.
WS_EX_TOPMOST Specifies that a window created with this style should be placed above all nontopmost windows and stay above them even when CWnd is deactivated. An application can use the SetWindowPos member function to add or remove this attribute.

lpClassName

Points to a null-terminated character string that names the Windows class (a WNDCLASS struct). The class name can be any name registered with the AfxRegisterWndClass function or any of the predefined control-class names. It must not be NULL.

lpWindowName

Points to a null-terminated character string that contains the window name.

dwStyle

Specifies the Windows style of CWnd.

x

Specifies the initial x-position of the CWnd window.

y

Specifies the initial top position of the CWnd window.

nWidth

Specifies the width (in device units) of the CWnd window.

nHeight

Specifies the height (in device units) of the CWnd window.

hwndParent

Identifies the parent or owner window of the CWnd window being created. Use NULL for top-level windows.

nIDorHMenu

Identifies a menu or a child-window identifier. The meaning depends on the style of the window.

Remarks

Creates an overlapped, pop-up, or child window with the extended style specified in dwExStyle.

The CreateEx parameters specify the WNDCLASS, window title, window style, and (optionally) initial position and size of the window. CreateEx also specifies the window's parent (if any) and ID.

When CreateEx executes, Windows sends the WM_GETMINMAXINFO, WM_NCCREATE, WM_NCCALCSIZE, and WM_CREATE messages to the window.

To extend the default message handling, derive a class from CWnd, add a message map to the new class, and provide member functions for the above messages. Override OnCreate, for example, to perform needed initialization for a new class.

Override further OnMessage message handlers to add further functionality to your derived class.

If the WS_VISIBLE style is given, Windows sends the window all the messages required to activate and show the window. If the window style specifies a title bar, the window title pointed to by the lpWindowName parameter is displayed in the title bar.

The dwStyle parameter can be any combination of the following window styles.

Style Meaning

DS_LOCALEDIT Specifies that edit controls in the dialog box will use memory in the application's data segment. By default, all edit controls in dialog boxes use memory outside the application's data segment. This feature may be suppressed by adding the DS_LOCALEDIT flag to the Style command for the dialog box. If this flag is not used, EM_GETHANDLE and EM_SETHANDLE messages must not be used since the storage for the control is not in the application's data segment. This feature does not affect edit controls created outside of dialog boxes.
DS_MODALFRAME Creates a dialog box with a modal dialog-box frame that can be combined with a title bar and Control menu by specifying the WS_CAPTION and WS_SYSMENU styles.
DS_NOIDLEMSG Suppresses WM_ENTERIDLE messages that Windows would otherwise send to the owner of the dialog box while the dialog box is displayed.
DS_SYSMODAL Creates a system-modal dialog box.
WS_BORDER Creates a window that has a border.
WS_CAPTION Creates a window that has a title bar (implies the WS_BORDER style). This style cannot be used with the WS_DLGFRAME style.
WS_CHILD Creates a child window. Cannot be used with the WS_POPUP style.
WS_CHILDWINDOW Same as the WS_CHILD style.
WS_CLIPCHILDREN Excludes the area occupied by child windows when drawing within the parent window. Used when creating the parent window.
WS_CLIPSIBLINGS Clips child windows relative to each other; that is, when a particular child window receives a paint message, the WS_CLIPSIBLINGS style clips all other overlapped child windows out of the region of the child window to be updated. (If WS_CLIPSIBLINGS is not given and child windows overlap, it is possible, when drawing within the client area of a child window, to draw within the client area of a neighboring child window.) For use with the WS_CHILD style only.
WS_DISABLED Creates a window that is initially disabled.
WS_DLGFRAME Creates a window with a double border but no title.
WS_GROUP Specifies the first control of a group of controls in which the user can move from one control to the next by using the ARROW keys. All controls defined with the WS_GROUP style after the first control belong to the same group. The next control with the WS_GROUP style ends the style group and starts the next group (that is, one group ends where the next begins). Only dialog boxes use this style.
WS_HSCROLL Creates a window that has a horizontal scroll bar.
WS_ICONIC Same as the WS_MINIMIZE style.
WS_MAXIMIZE Creates a window of maximum size.
WS_MAXIMIZEBOX Creates a window that has a maximize box.
WS_MINIMIZE Creates a window that is initially minimized. For use with the WS_OVERLAPPED style only.
WS_MINIMIZEBOX Creates a window that has a minimize box.
WS_OVERLAPPED Creates an overlapped window. An overlapped window has a caption and a border.
WS_OVERLAPPEDWINDOW Creates an overlapped window having the WS_OVERLAPPED, WS_CAPTION, WS_SYSMENU, WS_THICKFRAME, WS_MINIMIZEBOX, and WS_MAXIMIZEBOX styles.
WS_POPUP Creates a pop-up window. Cannot be used with the WS_CHILD style.
WS_POPUPWINDOW Creates a pop-up window that has the WS_BORDER, WS_POPUP, and WS_SYSMENU styles. The WS_CAPTION style must be combined with the WS_POPUPWINDOW style to make the Control menu visible.
WS_SIZEBOX Same as the WS_THICKFRAME style.
WS_SYSMENU Creates a window that has a Control-menu box in its title bar. Used only for windows with title bars.
WS_TABSTOP Specifies one of any number of controls through which the user can move by using the TAB key. The TAB key moves the user to the next control specified by the WS_TABSTOP style. Only dialog boxes use this style.
WS_THICKFRAME Creates a window with a thick frame that can be used to size the window.
WS_TILED Same as the WS_OVERLAPPED style.
WS_TILEDWINDOW Same as the WS_OVERLAPPEDWINDOW style.
WS_VISIBLE Creates a window that is initially visible. This applies to overlapped and pop-up windows.
WS_VSCROLL Creates a window that has a vertical scroll bar.

Return Value

TRUE if the CWnd window is created; otherwise FALSE.

See Also

::CreateWindowEx