The CreateWindow function creates an overlapped, pop-up, or child window. It specifies the window class, window title, window style, and (optionally) the initial position and size of the window. The function also specifies the window’s parent or owner, if any, and the window’s menu.
HWND CreateWindow(
LPCTSTR lpClassName, |
// pointer to registered class name |
LPCTSTR lpWindowName, |
// pointer to window name |
DWORD dwStyle, |
// window style |
int x, |
// horizontal position of window |
int y, |
// vertical position of window |
int nWidth, |
// window width |
int nHeight, |
// window height |
HWND hWndParent, |
// handle to parent or owner window |
HMENU hMenu, |
// handle to menu or child-window identifier |
HANDLE hInstance, |
// handle to application instance |
LPVOID lpParam |
// pointer to window-creation data |
); |
If lpClassName is a string, it specifies the window class name. The
class name can be any name registered with the RegisterClass
function or any of the predefined control-class names. For a complete list,
see the following Remarks section.
If this parameter is set to CW_USEDEFAULT, Windows selects the default
position for the window’s upper-left corner and ignores the y
parameter. CW_USEDEFAULT is valid only for overlapped windows; if it is
specified for a pop-up or child window, the x and y parameters
are set to zero.
If an overlapped window is created with the WS_VISIBLE style bit set and the x
parameter is set to CW_USEDEFAULT, Windows ignores the y parameter.
If the function succeeds, the return value is the handle to the new window.
If the function fails, the return value is NULL. To get extended error information, call GetLastError.
Before returning, CreateWindow sends a WM_CREATE message to the window procedure.
For overlapped, pop-up, and child windows, CreateWindow sends WM_CREATE, WM_GETMINMAXINFO, and WM_NCCREATE messages to the window. The lParam parameter of the WM_CREATE message contains a pointer to a CREATESTRUCT structure. If the WS_VISIBLE style is specified, CreateWindow 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 lpWindowName is displayed in the title bar. When using CreateWindow to create controls, such as buttons, check boxes, and static controls, use lpWindowName to specify the text of the control.
If you specify Windows version 4.x when linking your application, its windows cannot have caption buttons unless they also have window menus. This is not a requirement for applications that you linked specifying Windows version 3.x.
The following predefined control classes can be specified in the lpClassName parameter:
Class |
Meaning |
BUTTON |
Designates a small rectangular child window that represents a button the user can click to turn it on or off. Button controls can be used alone or in groups, and they can either be labeled or appear without text. Button controls typically change appearance when the user clicks them. |
COMBOBOX |
Designates a control consisting of a list box and a selection field similar to an edit control. When using this style, an application should either display the list box at all times or enable a drop-down list box. |
Depending on the style of the combo box, the user can or cannot edit the contents of the selection field. If the list box is visible, typing characters into the selection field highlights the first list box entry that matches the characters typed. Conversely, selecting an item in the list box displays the selected text in the selection field. | |
EDIT |
Designates a rectangular child window into which the user can type text from the keyboard. The user selects the control and gives it the keyboard focus by clicking it or moving to it by pressing the TAB key. The user can type text when the edit control displays a flashing caret; use the mouse to move the cursor, select characters to be replaced, or position the cursor for inserting characters; or use the BACKSPACE key to delete characters. |
Edit controls use the variable-pitch system font and display characters from the ANSI character set. The WM_SETFONT message can also be sent to the edit control to change the default font. | |
Edit controls expand tab characters into as many space characters as are required to move the caret to the next tab stop. Tab stops are assumed to be at every eighth character position. | |
LISTBOX |
Designates a list of character strings. Specify this control whenever an application must present a list of names, such as filenames, from which the user can choose. The user can select a string by clicking it. A selected string is highlighted, and a notification message is passed to the parent window. Use a vertical or horizontal scroll bar with a list box to scroll lists that are too long for the control window. The list box automatically hides or shows the scroll bar, as needed. |
MDICLIENT |
Designates an MDI client window. This window receives messages that control the MDI application’s child windows. The recommended style bits are WS_CLIPCHILDREN and WS_CHILD. Specify the WS_HSCROLL and WS_VSCROLL styles to create an MDI client window that allows the user to scroll MDI child windows into view. |
SCROLLBAR |
Designates a rectangle that contains a scroll box and has direction arrows at both ends. The scroll bar sends a notification message to its parent window whenever the user clicks the control. The parent window is responsible for updating the position of the scroll box, if necessary. Scroll bar controls have the same appearance and function as scroll bars used in ordinary windows. Unlike scroll bars, however, scroll bar controls can be positioned anywhere in a window for use whenever scrolling input is needed for a window. |
The scroll bar class also includes size box controls. A size box is a small rectangle the user can expand to change the size of the window. | |
STATIC |
Designates a simple text field, box, or rectangle used to label, box, or separate other controls. Static controls take no input and provide no output. |
The following window styles can be specified in the dwStyle parameter:
Style |
Meaning |
WS_BORDER |
Creates a window that has a thin-line border. |
WS_CAPTION |
Creates a window that has a title bar (includes the WS_BORDER style). |
WS_CHILD |
Creates a child window. This style 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 occurs within the parent window. This style is used when creating the parent window. |
WS_CLIPSIBLINGS |
Clips child windows relative to each other; that is, when a particular child window receives a WM_PAINT message, the WS_CLIPSIBLINGS style clips all other overlapping child windows out of the region of the child window to be updated. If WS_CLIPSIBLINGS is not specified 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. |
WS_DISABLED |
Creates a window that is initially disabled. A disabled window cannot receive input from the user. |
WS_DLGFRAME |
Creates a window that has a border of a style typically used with dialog boxes. A window with this style cannot have a title bar. |
WS_GROUP |
Specifies the first control of a group of controls. The group consists of this first control and all controls defined after it, up to the next control with the WS_GROUP style. The first control in each group usually has the WS_TABSTOP style so that the user can move from group to group. The user can subsequently change the keyboard focus from one control in the group to the next control in the group by using the direction keys. |
WS_HSCROLL |
Creates a window that has a horizontal scroll bar. |
WS_ICONIC |
Creates a window that is initially minimized. Same as the WS_MINIMIZE style. |
WS_MAXIMIZE |
Creates a window that is initially maximized. |
WS_MAXIMIZEBOX |
Creates a window that has a Maximize button. Cannot be combined with the WS_EX_CONTEXTHELP style. The WS_SYSMENU style must also be specified. |
WS_MINIMIZE |
Creates a window that is initially minimized. Same as the WS_ICONIC style. |
WS_MINIMIZEBOX |
Creates a window that has a Minimize button. Cannot be combined with the WS_EX_CONTEXTHELP style. The WS_SYSMENU style must also be specified. |
WS_OVERLAPPED |
Creates an overlapped window. An overlapped window has a title bar and a border. Same as the WS_TILED style. |
WS_OVERLAPPEDWINDOW |
Creates an overlapped window with the WS_OVERLAPPED, WS_CAPTION, WS_SYSMENU, WS_THICKFRAME, WS_MINIMIZEBOX, and WS_MAXIMIZEBOX styles. Same as the WS_TILEDWINDOW style. |
WS_POPUP |
Creates a pop-up window. This style cannot be used with the WS_CHILD style. |
WS_POPUPWINDOW |
Creates a pop-up window with WS_BORDER, WS_POPUP, and WS_SYSMENU styles. The WS_CAPTION and WS_POPUPWINDOW styles must be combined to make the window menu visible. |
WS_SIZEBOX |
Creates a window that has a sizing border. Same as the WS_THICKFRAME style. |
WS_SYSMENU |
Creates a window that has a window-menu on its title bar. The WS_CAPTION style must also be specified. |
WS_TABSTOP |
Specifies a control that can receive the keyboard focus when the user presses the TAB key. Pressing the TAB key changes the keyboard focus to the next control with the WS_TABSTOP style. |
WS_THICKFRAME |
Creates a window that has a sizing border. Same as the WS_SIZEBOX style. |
WS_TILED |
Creates an overlapped window. An overlapped window has a title bar and a border. Same as the WS_OVERLAPPED style. |
WS_TILEDWINDOW |
Creates an overlapped window with the WS_OVERLAPPED, WS_CAPTION, WS_SYSMENU, WS_THICKFRAME, WS_MINIMIZEBOX, and WS_MAXIMIZEBOX styles. Same as the WS_OVERLAPPEDWINDOW style. |
WS_VISIBLE |
Creates a window that is initially visible. |
WS_VSCROLL |
Creates a window that has a vertical scroll bar. |
The following button styles (in the BUTTON class) can be specified in the dwStyle parameter:
Style |
Meaning |
BS_3STATE |
Creates a button that is the same as a check box, except that the box can be grayed as well as checked or unchecked. Use the grayed state to show that the state of the check box is not determined. |
BS_AUTO3STATE |
Creates a button that is the same as a three-state check box, except that the box changes its state when the user selects it. The state cycles through checked, grayed, and unchecked. |
BS_AUTOCHECKBOX |
Creates a button that is the same as a check box, except that the check state automatically toggles between checked and unchecked each time the user selects the check box. |
BS_AUTORADIOBUTTON |
Creates a button that is the same as a radio button, except that when the user selects it, Windows automatically sets the button’s check state to checked and automatically sets the check state for all other buttons in the same group to unchecked. |
BS_CHECKBOX |
Creates a small, empty check box with text. By default, the text is displayed to the right of the check box. To display the text to the left of the check box, combine this flag with the BS_LEFTTEXT style (or with the equivalent BS_RIGHTBUTTON style). |
BS_DEFPUSHBUTTON |
Creates a push button that behaves like a BS_PUSHBUTTON style button, but also has a heavy black border. If the button is in a dialog box, the user can select the button by pressing the ENTER key, even when the button does not have the input focus. This style is useful for enabling the user to quickly select the most likely (default) option. |
BS_GROUPBOX |
Creates a rectangle in which other controls can be grouped. Any text associated with this style is displayed in the rectangle’s upper left corner. |
BS_LEFTTEXT |
Places text on the left side of the radio button or check box when combined with a radio button or check box style. Same as the BS_RIGHTBUTTON style. |
BS_OWNERDRAW |
Creates an owner-drawn button. The owner window receives a WM_MEASUREITEM message when the button is created and a WM_DRAWITEM message when a visual aspect of the button has changed. Do not combine the BS_OWNERDRAW style with any other button styles. |
BS_PUSHBUTTON |
Creates a push button that posts a WM_COMMAND message to the owner window when the user selects the button. |
BS_RADIOBUTTON |
Creates a small circle with text. By default, the text is displayed to the right of the circle. To display the text to the left of the circle, combine this flag with the BS_LEFTTEXT style (or with the equivalent BS_RIGHTBUTTON style). Use radio buttons for groups of related, but mutually exclusive choices. |
BS_USERBUTTON |
Obsolete, but provided for compatibility with 16-bit versions of Windows. Win32-based applications should use BS_OWNERDRAW instead. |
BS_BITMAP |
Specifies that the button displays a bitmap. |
BS_BOTTOM |
Places text at the bottom of the button rectangle. |
BS_CENTER |
Centers text horizontally in the button rectangle. |
BS_ICON |
Specifies that the button displays an icon. |
BS_LEFT |
Left-justifies the text in the button rectangle. However, if the button is a check box or radio button that does not have the BS_RIGHTBUTTON style, the text is left justified on the right side of the check box or radio button. |
BS_MULTILINE |
Wraps the button text to multiple lines if the text string is too long to fit on a single line in the button rectangle. |
BS_NOTIFY |
Enables a button to send BN_DBLCLK, BN_KILLFOCUS, and BN_SETFOCUS notification messages to its parent window. Note that buttons send the BN_CLICKED notification message regardless of whether it has this style. |
BS_PUSHLIKE |
Makes a button (such as a check box, three-state check box, or radio button) look and act like a push button. The button looks raised when it isn’t pushed or checked, and sunken when it is pushed or checked. |
BS_RIGHT |
Right-justifies text in the button rectangle. However, if the button is a check box or radio button that does not have the BS_RIGHTBUTTON style, the text is right justified on the right side of the check box or radio button. |
BS_RIGHTBUTTON |
Positions a radio button’s circle or a check box’s square on the right side of the button rectangle. Same as the BS_LEFTTEXT style. |
BS_TEXT |
Specifies that the button displays text. |
BS_TOP |
Places text at the top of the button rectangle. |
BS_VCENTER |
Places text in the middle (vertically) of the button rectangle. |
The following combo box styles (in the COMBOBOX class) can be specified in the dwStyle parameter:
Style |
Meaning |
CBS_AUTOHSCROLL |
Automatically scrolls the text in an edit control to the right when the user types a character at the end of the line. If this style is not set, only text that fits within the rectangular boundary is allowed. |
CBS_DISABLENOSCROLL |
Shows a disabled vertical scroll bar in the list box when the box does not contain enough items to scroll. Without this style, the scroll bar is hidden when the list box does not contain enough items. |
CBS_DROPDOWN |
Similar to CBS_SIMPLE, except that the list box is not displayed unless the user selects an icon next to the edit control. |
CBS_DROPDOWNLIST |
Similar to CBS_DROPDOWN, except that the edit control is replaced by a static text item that displays the current selection in the list box. |
CBS_HASSTRINGS |
Specifies that an owner-drawn combo box contains items consisting of strings. The combo box maintains the memory and address for the strings, so the application can use the CB_GETLBTEXT message to retrieve the text for a particular item. |
CBS_LOWERCASE |
Converts to lowercase any uppercase characters entered into the edit control of a combo box. |
CBS_NOINTEGRALHEIGHT |
Specifies that the size of the combo box is exactly the size specified by the application when it created the combo box. Normally, Windows sizes a combo box so that it does not display partial items. |
CBS_OEMCONVERT |
Converts text entered in the combo box edit control. The text is converted from the Windows character set to the OEM character set and then back to the Windows set. This ensures proper character conversion when the application calls the CharToOem function to convert a Windows string in the combo box to OEM characters. This style is most useful for combo boxes that contain filenames and applies only to combo boxes created with the CBS_SIMPLE or CBS_DROPDOWN style. |
CBS_OWNERDRAWFIXED |
Specifies that the owner of the list box is responsible for drawing its contents and that the items in the list box are all the same height. The owner window receives a WM_MEASUREITEM message when the combo box is created and a WM_DRAWITEM message when a visual aspect of the combo box has changed. |
CBS_OWNERDRAWVARIABLE |
Specifies that the owner of the list box is responsible for drawing its contents and that the items in the list box are variable in height. The owner window receives a WM_MEASUREITEM message for each item in the combo box when you create the combo box; the owner window receives a WM_DRAWITEM message when a visual aspect of the combo box has changed. |
CBS_SIMPLE |
Displays the list box at all times. The current selection in the list box is displayed in the edit control. |
CBS_SORT |
Automatically sorts strings entered into the list box. |
CBS_UPPERCASE |
Converts to uppercase any lowercase characters entered into the edit control of a combo box. |
The following edit control styles (in the EDIT class) can be specified in the dwStyle parameter:
Style |
Meaning |
ES_AUTOHSCROLL |
Automatically scrolls text to the right by 10 characters when the user types a character at the end of the line. When the user presses the ENTER key, the control scrolls all text back to position zero. |
ES_AUTOVSCROLL |
Automatically scrolls text up one page when the user presses the ENTER key on the last line. |
ES_CENTER |
Centers text in a multiline edit control. |
ES_LEFT |
Left-aligns text. |
ES_LOWERCASE |
Converts all characters to lowercase as they are typed into the edit control. |
ES_MULTILINE |
Designates a multiline edit control. The default is single-line edit control. |
When the multiline edit control is in a dialog box, the default response to pressing the ENTER key is to activate the default button. To use the ENTER key as a carriage return, use the ES_WANTRETURN style. | |
When the multiline edit control is not in a dialog box and the ES_AUTOVSCROLL style is specified, the edit control shows as many lines as possible and scrolls vertically when the user presses the ENTER key. If you do not specify ES_AUTOVSCROLL, the edit control shows as many lines as possible and beeps if the user presses the ENTER key when no more lines can be displayed. | |
If you specify the ES_AUTOHSCROLL style, the multiline edit control automatically scrolls horizontally when the caret goes past the right edge of the control. To start a new line, the user must press the ENTER key. If you do not specify ES_AUTOHSCROLL, the control automatically wraps words to the beginning of the next line when necessary. A new line is also started if the user presses the ENTER key. The window size determines the position of the word wrap. If the window size changes, the word wrapping position changes and the text is redisplayed. | |
Multiline edit controls can have scroll bars. An edit control with scroll bars processes its own scroll bar messages. Note that edit controls without scroll bars scroll as described in the previous paragraphs and process any scroll messages sent by the parent window. | |
ES_NOHIDESEL |
Negates the default behavior for an edit control. The default behavior hides the selection when the control loses the input focus and inverts the selection when the control receives the input focus. If you specify ES_NOHIDESEL, the selected text is inverted, even if the control does not have the focus. |
ES_NUMBER |
Allows only digits to be entered into the edit control. |
ES_OEMCONVERT |
Converts text entered in the edit control. The text is converted from the Windows character set to the OEM character set and then back to the Windows set. This ensures proper character conversion when the application calls the CharToOem function to convert a Windows string in the edit control to OEM characters. This style is most useful for edit controls that contain filenames. |
ES_PASSWORD |
Displays an asterisk (*) for each character typed into the edit control. You can use the EM_SETPASSWORDCHAR message to change the character that is displayed. |
ES_READONLY |
Prevents the user from typing or editing text in the edit control. |
ES_RIGHT |
Right-aligns text in a multiline edit control. |
ES_UPPERCASE |
Converts all characters to uppercase as they are typed into the edit control. |
ES_WANTRETURN |
Specifies that a carriage return be inserted when the user presses the ENTER key while entering text into a multiline edit control in a dialog box. If you do not specify this style, pressing the ENTER key has the same effect as pressing the dialog box’s default push button. This style has no effect on a single-line edit control. |
The following list box control styles (in the LISTBOX class) can be specified in the dwStyle parameter:
Style |
Meaning |
LBS_DISABLENOSCROLL |
Shows a disabled vertical scroll bar for the list box when the box does not contain enough items to scroll. If you do not specify this style, the scroll bar is hidden when the list box does not contain enough items. |
LBS_EXTENDEDSEL |
Allows multiple items to be selected by using the SHIFT key and the mouse or special key combinations. |
LBS_HASSTRINGS |
Specifies that a list box contains items consisting of strings. The list box maintains the memory and addresses for the strings so the application can use the LB_GETTEXT message to retrieve the text for a particular item. By default, all list boxes except owner-drawn list boxes have this style. You can create an owner-drawn list box either with or without this style. |
LBS_MULTICOLUMN |
Specifies a multicolumn list box that is scrolled horizontally. The LB_SETCOLUMNWIDTH message sets the width of the columns. |
LBS_MULTIPLESEL |
Turns string selection on or off each time the user clicks or double-clicks a string in the list box. The user can select any number of strings. |
LBS_NODATA |
Specifies a no-data list box. Specify this style when the count of items in the list box will exceed one thousand. A no-data list box must also have the LBS_OWNERDRAWFIXED style, but must not have the LBS_SORT or LBS_HASSTRINGS style. |
A no-data list box resembles an owner-drawn list box except that it contains no string or bitmap data for an item. Commands to add, insert, or delete an item always ignore any given item data; requests to find a string within the list box always fail. Windows sends the WM_DRAWITEM message to the owner window when an item must be drawn. The itemID member of the DRAWITEMSTRUCT structure passed with the WM_DRAWITEM message specifies the line number of the item to be drawn. A no-data list box does not send a WM_DELETEITEM message. | |
LBS_NOINTEGRALHEIGHT |
Specifies that the size of the list box is exactly the size specified by the application when it created the list box. Normally, Windows sizes a list box so that the list box does not display partial items. |
LBS_NOREDRAW |
Specifies that the list box’s appearance is not updated when changes are made. You can change this style at any time by sending a WM_SETREDRAW message. |
LBS_NOSEL |
Specifies that the list box contains items that can be viewed but not selected. |
LBS_NOTIFY |
Notifies the parent window with an input message whenever the user clicks or double-clicks a string in the list box. |
LBS_OWNERDRAWFIXED |
Specifies that the owner of the list box is responsible for drawing its contents and that the items in the list box are the same height. The owner window receives a WM_MEASUREITEM message when the list box is created and a WM_DRAWITEM message when a visual aspect of the list box has changed. |
LBS_OWNERDRAWVARIABLE |
Specifies that the owner of the list box is responsible for drawing its contents and that the items in the list box are variable in height. The owner window receives a WM_MEASUREITEM message for each item in the combo box when the combo box is created and a WM_DRAWITEM message when a visual aspect of the combo box has changed. |
LBS_SORT |
Sorts strings in the list box alphabetically. |
LBS_STANDARD |
Sorts strings in the list box alphabetically. The parent window receives an input message whenever the user clicks or double-clicks a string. The list box has borders on all sides. |
LBS_USETABSTOPS |
Enables a list box to recognize and expand tab characters when drawing its strings. You can use the LB_SETTABSTOPS message to specify tab stop positions. The default tab positions are 32 dialog template units apart. Dialog template units are the device-independent units used in dialog box templates. To convert measurements from dialog template units to screen units (pixels), use the MapDialogRect function. |
LBS_WANTKEYBOARDINPUT |
Specifies that the owner of the list box receives WM_VKEYTOITEM messages whenever the user presses a key and the list box has the input focus. This enables an application to perform special processing on the keyboard input. |
The following scroll bar styles (in the SCROLLBAR class) can be specified in the dwStyle parameter:
Style |
Meaning |
SBS_BOTTOMALIGN |
Aligns the bottom edge of the scroll bar with the bottom edge of the rectangle defined by the parameters x, y, nWidth, and nHeight. The scroll bar has the default height for system scroll bars. Use this style with the SBS_HORZ style. |
SBS_HORZ |
Designates a horizontal scroll bar. If neither the SBS_BOTTOMALIGN nor SBS_TOPALIGN style is specified, the scroll bar has the height, width, and position defined by x, y, nWidth, and nHeight. |
SBS_LEFTALIGN |
Aligns the left edge of the scroll bar with the left edge of the rectangle defined by the parameters x, y, nWidth, and nHeight. The scroll bar has the default width for system scroll bars. Use this style with the SBS_VERT style. |
SBS_RIGHTALIGN |
Aligns the right edge of the scroll bar with the right edge of the rectangle defined by the parameters x, y, nWidth, and nHeight. The scroll bar has the default width for system scroll bars. Use this style with the SBS_VERT style. |
SBS_SIZEBOX |
Designates a size box. If you specify neither the SBS_SIZEBOXBOTTOMRIGHTALIGN nor the SBS_SIZEBOXTOPLEFTALIGN style, the size box has the height, width, and position specified by the parameters x, y, nWidth, and nHeight. |
SBS_SIZEBOXBOTTOMRIGHTALIGN |
Aligns the lower-right corner of the size box with the lower-right corner of the rectangle specified by the parameters x, y, nWidth, and nHeight. The size box has the default size for system size boxes. Use this style with the SBS_SIZEBOX style. |
SBS_SIZEBOXTOPLEFTALIGN |
Aligns the upper-left corner of the size box with the upper-left corner of the rectangle specified by the parameters x, y, nWidth, and nHeight. The size box has the default size for system size boxes. Use this style with the SBS_SIZEBOX style. |
SBS_SIZEGRIP |
Same as SBS_SIZEBOX, but with a raised edge. |
SBS_TOPALIGN |
Aligns the top edge of the scroll bar with the top edge of the rectangle defined by the parameters x, y, nWidth, and nHeight. The scroll bar has the default height for system scroll bars. Use this style with the SBS_HORZ style. |
SBS_VERT |
Designates a vertical scroll bar. If you specify neither the SBS_RIGHTALIGN nor the SBS_LEFTALIGN style, the scroll bar has the height, width, and position specified by the parameters x, y, nWidth, and nHeight. |
The following static control styles (in the STATIC class) can be specified in the dwStyle parameter. A static control can have only one of these styles:
Style |
Description |
SS_BITMAP |
Specifies a bitmap is to be displayed in the static control. The error code text is the name of a bitmap (not a filename) defined elsewhere in the resource file. The style ignores the nWidth and nHeight parameters; the control automatically sizes itself to accommodate the bitmap. |
SS_BLACKFRAME |
Specifies a box with a frame drawn in the same color as the window frames. This color is black in the default Windows color scheme. |
SS_BLACKRECT |
Specifies a rectangle filled with the current window frame color. This color is black in the default Windows color scheme. |
SS_CENTER |
Specifies a simple rectangle and centers the error code text in the rectangle. The text is formatted before it is displayed. Words that extend past the end of a line are automatically wrapped to the beginning of the next centered line. |
SS_CENTERIMAGE |
Specifies that the midpoint of a static control with the SS_BITMAP or SS_ICON style is to remain fixed when the control is resized. The four sides are adjusted to accommodate a new bitmap or icon. If a static control has the SS_BITMAP style and the bitmap is smaller than the control’s client area, the client area is filled with the color of the pixel in the upper-left corner of the bitmap. If a static control has the SS_ICON style, the icon does not appear to paint the client area. |
SS_GRAYFRAME |
Specifies a box with a frame drawn with the same color as the screen background (desktop). This color is gray in the default Windows color scheme. |
SS_GRAYRECT |
Specifies a rectangle filled with the current screen background color. This color is gray in the default Windows color scheme. |
SS_ICON |
Specifies an icon displayed in the dialog box. The given text is the name of an icon (not a filename) defined elsewhere in the resource file. The style ignores the nWidth and nHeight parameters; the icon automatically sizes itself. |
SS_LEFT |
Specifies a simple rectangle and left-aligns the given text in the rectangle. The text is formatted before it is displayed. Words that extend past the end of a line are automatically wrapped to the beginning of the next left-aligned line. |
SS_LEFTNOWORDWRAP |
Specifies a simple rectangle and left-aligns the given text in the rectangle. Tabs are expanded but words are not wrapped. Text that extends past the end of a line is clipped. |
SS_METAPICT |
Specifies a metafile picture is to be displayed in the static control. The given text is the name of a metafile picture (not a filename) defined elsewhere in the resource file. A metafile static control has a fixed size; the metafile picture is scaled to fit the static control’s client area. |
SS_NOPREFIX |
Prevents interpretation of any ampersand (&) characters in the control’s text as accelerator prefix characters. These are displayed with the ampersand removed and the next character in the string underlined. This static control style may be included with any of the defined static controls. |
An application can combine SS_NOPREFIX with other styles by using the bitwise OR (|) operator. This can be useful when filenames or other strings that may contain an ampersand (&) must be displayed in a static control in a dialog box. | |
SS_NOTIFY |
Sends the parent window STN_CLICKED and STN_DBLCLK notification messages when the user clicks or double clicks the control. |
SS_RIGHT |
Specifies a simple rectangle and right-aligns the given text in the rectangle. The text is formatted before it is displayed. Words that extend past the end of a line are automatically wrapped to the beginning of the next right-aligned line. |
SS_RIGHTIMAGE |
Specifies that the bottom-right corner of a static control with the SS_BITMAP or SS_ICON style is to remain fixed when the control is resized. Only the top and left sides are adjusted to accommodate a new bitmap or icon. |
SS_SIMPLE |
Specifies a simple rectangle and displays a single line of left-aligned text in the rectangle. The text line cannot be shortened or altered in any way. The control’s parent window or dialog box must not process the WM_CTLCOLORSTATIC message. |
SS_WHITEFRAME |
Specifies a box with a frame drawn with the same color as the window backgrounds. This color is white in the default Windows color scheme. |
SS_WHITERECT |
Specifies a rectangle filled with the current window background color. This color is white in the default Windows color scheme. |
The following dialog box styles can be specified in the dwStyle parameter:
Style |
Meaning |
DS_3DLOOK |
Gives the dialog box a nonbold font and draws three-dimensional borders around control windows in the dialog box. The DS_3DLOOK style is required only by Win32-based applications compiled for versions of Windows earlier than Windows 95 or Windows NT 4.0. The system automatically applies the three-dimensional look to dialog boxes created by applications compiled for current versions of Windows. |
DS_ABSALIGN |
Indicates that the coordinates of the dialog box are screen coordinates; otherwise, Windows assumes they are client coordinates. |
DS_CENTER |
Centers the dialog box in the working area; that is, the area not obscured by the tray. |
DS_CENTERMOUSE |
Centers the mouse cursor in the dialog box. |
DS_CONTEXTHELP |
Includes a question mark in the title bar of the dialog box. When the user clicks the question mark, the cursor changes to a question mark with a pointer. If the user then clicks a control in the dialog box, the control receives a WM_HELP message. The control should pass the message to the dialog procedure, which should call the WinHelp function using the HELP_WM_HELP command. The Help application displays a pop-up window that typically contains help for the control. Note that DS_CONTEXTHELP is just a placeholder. When the dialog box is created, the system checks for DS_CONTEXTHELP and, if it is there, adds WS_EX_CONTEXTHELP to the extended style of the dialog box. WS_EX_CONTEXTHELP cannot be used with the WS_MAXIMIZEBOX or WS_MINIMIZEBOX styles. |
DS_CONTROL |
Creates a dialog box that works well as a child window of another dialog box, much like a page in a property sheet. This style allows the user to tab among the control windows of a child dialog box, use its accelerator keys, and so on. |
DS_FIXEDSYS |
Use SYSTEM_FIXED_FONT instead of SYSTEM_FONT. |
DS_LOCALEDIT |
Applies to 16-bit applications only. This style directs edit controls in the dialog box to allocate memory from the application’s data segment. Otherwise, edit controls allocate storage from a global memory object. |
DS_MODALFRAME |
Creates a dialog box with a modal dialog-box frame that can be combined with a title bar and window menu by specifying the WS_CAPTION and WS_SYSMENU styles. |
DS_NOFAILCREATE |
Creates the dialog box even if errors occur ¾ for example, if a child window cannot be created or if the system cannot create a special data segment for an edit control. |
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_RECURSE |
Dialog box style for control-like dialog boxes. |
DS_SETFONT |
Indicates that the dialog box template (the DLGTEMPLATE structure) contains two additional members specifying a font name and point size. The corresponding font is used to display text within the dialog box client area and within the dialog box controls. Windows passes the handle of the font to the dialog box and to each control by sending them the WM_SETFONT message. |
DS_SETFOREGROUND |
Does not apply to 16-bit versions of Microsoft Windows. This style brings the dialog box to the foreground. Internally, Windows calls the SetForegroundWindow function for the dialog box. |
DS_SYSMODAL |
Creates a system-modal dialog box. This style causes the dialog box to have the WS_EX_TOPMOST style, but otherwise has no effect on the dialog box or the behavior of other windows in the system when the dialog box is displayed. |
Windows 95: The system can support a maximum of 16,364 window handles.
CharToOem, CLIENTCREATESTRUCT, CreateDialog, CREATESTRUCT, CreateWindowEx, DialogBox, DLGTEMPLATE, DRAWITEMSTRUCT, GetDialogBaseUnits, GlobalAddAtom, LB_GETTEXT, LB_SETCOLUMNWIDTH, MessageBox, RegisterClass, SetForegroundWindow, WM_COMMAND, WM_CREATE, WM_DELETEITEM, WM_DRAWITEM, WM_ENTERIDLE, WM_GETMINMAXINFO, WM_MEASUREITEM, WM_NCCREATE, WM_PAINT, WM_SETFONT, WM_SETREDRAW, WM_VKEYTOITEM
file: /Techref/os/win/api/win32/func/src/f11_14.htm, 68KB, , updated: 2000/4/7 11:19, local time: 2024/11/24 07:01,
18.188.219.131:LOG IN
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://massmind.org/techref/os/win/api/win32/func/src/f11_14.htm"> CreateWindow</A> |
Did you find what you needed? |
Welcome to massmind.org! |
Welcome to massmind.org! |
.