Window Styles

Description & Usage

Window styles determine a great deal about how a window looks and functions. Upon creation, a window's functionality and behavior depend largely on the styles given to it (most of a style's effect upon the window takes place when it is created). While there is a group of window styles which apply to most window classes, there are additional styles which can only be attributed to windows belonging to certain operating system-defined classes. These special classes are the ones which create various common controls throughout Windows. Generally, any number of window styles can be combined.

Visual Basic-Specific Issues

None.

Generic Window Styles

The following window styles can usually be used with all windows.

WS_BORDER
The window has a thin-line border.
WS_CAPTION
The window has a title bar.
WS_CHILD
The window is a child window. These windows cannot have menu bars nor can have the WS_POPUP style.
WS_CHILDWINDOW
Same as WS_CHILD.
WS_CLIPCHILDREN
For a parent window, exclude the areas occupied by child windows when drawing within the window (to avoid drawing on any child windows).
WS_CLIPSIBLINGS
For a child window, exclude the areas occupied by fellow children of the window's parent when drawing within the window (to avoid drawing on any sibling windows).
WS_DISABLED
The window is disabled.
WS_DLGFRAME
The window has a border style typical of dialog boxes. These windows cannot have a title bar.
WS_GROUP
Identifies the first control in a group of controls. Any controls following this one are assumed to be part of this control's group, until a control with the WS_GROUP style is encountered.
WS_HSCROLL
The window has a horizontal scroll bar.
WS_ICONIC
Same as WS_MINIMIZED.
WS_MAXIMIZE
The window is maximized.
WS_MAXIMIZEBOX
The window has a maximize button. This cannot be used on windows having the WS_EX_CONTEXTHELP extended window style. The WS_SYSMENU window style must also be specified.
WS_MINIMIZE
The window is minimized.
WS_MINIMIZEBOX
The window has a minimize button. This cannot be used on windows having the WS_EX_CONTEXTHELP extended window style. The WS_SYSMENU window style must also be specified.
WS_OVERLAPPED
The window is an overlapped window, which as a title bar and a border.
WS_OVERLAPPEDWINDOW
The window is an overlapped window, having a title bar, a sizing border, a title bar, a system menu, and minimize and maximize boxes.
WS_POPUP
The window is a popup window. This cannot be used with the WS_CHILD window style.
WS_POPUPWINDOW
The window is a popup window, having a thin-line border and system menu. The window can only be visible if it also has the WS_CAPTION window style.
WS_SIZEBOX
Same as WS_THICKFRAME.
WS_SYSMENU
The window has a system menu on its title bar. The WS_CAPTION window style must also be specified.
WS_TABSTOP
The control can press Tab repeatedly to set the focus to this control.
WS_THICKFRAME
The window has a sizing border.
WS_TILED
Same as WS_OVERLAPPED.
WS_TILEDWINDOW
Same as WS_OVERLAPPEDWINDOW.
WS_VISIBLE
The window is visible.
WS_VSCROLL
The window has a vertical scroll bar.

Button Control Styles

The following window styles can only be used by button controls -- windows created out of window class "BUTTON".

BS_3STATE
The button is a check box which has three states: checked, grayed, and cleared.
BS_AUTO3STATE
The button is a check box which has three states: checked, grayed, and cleared. The button automatically changes its state when the user selects it.
BS_AUTOCHECKBOX
The button is a check box whose state toggles when the user selects it.
BS_AUTORADIOBUTTON
The button is a radio button whose state automatically changes to selected (and the state of all other radio buttons in the group to unselected) when the user selects it.
BS_BITMAP
The button displays a bitmap.
BS_BOTTOM
The button's text appears at the bottom of the button rectangle.
BS_CENTER
The button's text appears centered horizontally within the button rectangle.
BS_CHECKBOX
The button is a check box.
BS_DEFPUSHBUTTON
The button is the default push button in a dialog box, having a heavy black border.
BS_GROUPBOX
The window is a rectangular grouping frame in which other controls can be grouped.
BS_FLAT
The button is flat, not using the default 3D shading.
BS_ICON
The button displays an icon.
BS_LEFT
The text in the button rectangle is left-justified.
BS_LEFTTEXT
The radio or check box's text appears to the left of the button instead of to the right.
BS_MULTILINE
The button's text is wrapped across multiple lines if it cannot fit on a single line.
BS_NOTIFY
The button sends focus notification messages to its parent window.
BS_OWNERDRAW
The owner of the window is responsible for manually drawing it whenever it needs to be redrawn. This window style cannot be combined with any other button styles.
BS_PUSHBUTTON
The button is a push button.
BS_PUSHLIKE
The radio or check button takes on the appearance of a push button. A checked state makes the button look depressed; a cleared state makes the button look normal.
BS_RADIOBUTTON
The button is a radio button.
BS_RIGHT
The text in the button rectangle is right-justified.
BS_RIGHTBUTTON
Same as BS_LEFTTEXT.
BS_TEXT
The button displays text.
BS_TOP
The text appears at the top of the button rectangle.
BS_USERBUTTON
Obsolete; use BS_OWNERDRAW instead.
BS_VCENTER
The text appears centered vertically within the button rectangle.

Combo Box Control Styles

The following window styles can only be used by combo box controls -- windows created out of window class "COMBOBOX".

CBS_AUTOHSCROLL
Automatically scroll text to the right when the user types a character at the end of the line.
CBS_DISABLENOSCROLL
Show a disable the vertical scroll bar in the drop-down list box if it does not contain enough items to scroll. If this flag is not specified, such a scroll bar is not displayed.
CBS_DROPDOWN
Display the list box whenever the user clicks the drop-down button.
CBS_DROPDOWNLIST
Display the list box whenever the user click the drop-down button, and do not allow the user to change the combo box's selection if the list is not dropped down.
CBS_HASSTRINGS
The combo box is drawn manually by the application and contains strings. Either CBS_OWNERDRAWFICED or CBS_OWNERDRAWVARIABLE must also be specified.
CBS_LOWERCASE
Convert all text in the combo box to lowercase letters.
CBS_NOINTEGRALHEIGHT
Force the combo box to be exactly the size specified by the application, instead of allowing the operating system to slightly resize it to prevent displaying partial selections.
CBS_OEMCONVERT
Ensure that text in the combo box can readily be converted into the OEM character set.
CBS_OWNERDRAWFIXED
The owner of the combo box is fully responsible for drawing it manually, and all of the items in the combo box have the same height.
CBS_OWNERDRAWVARIABLE
The owner of the combo box is full responsible for drawing it manually, and the heights of the items in the combo box have can be different.
CBS_SIMPLE
Display the list box portion of the combo box at all times.
CBS_SORT
Automatically sort the strings added to the combo box.
CBS_UPPERCASE
Convert all text in the combo box to uppercase letters.

Edit Control Styles

The following window styles can only be used by edit controls -- windows created out of window class "EDIT".

ES_AUTOHSCROLL
Automatically scroll the text to the right when the user types a character at the end of the line. When the user pressed ENTER, scroll the text all the way back to the left.
ES_AUTOVSCROLL
Automatically scroll the text back up when the user presses ENTER on the last line.
ES_CENTER
Center the text horizontally.
ES_LEFT
Left-align the text.
ES_LOWERCASE
Convert all the characters to lowercase as they are typed.
ES_MULTILINE
The edit control displays multiple lines of text. If this flag is not specified, it can only display a single line of text.
ES_NOHIDESEL
Do not hide the selected text in the edit control even if the control loses focus.
ES_NUMBER
Only allow digits to be entered into the edit control.
ES_OEMCONVERT
Ensure that text in the edit control can readily be converted into the OEM character set.
ES_PASSWORD
Display an asterisk for each character typed into the edit control. This cannot be used with ES_MULTILINE.
ES_READONLY
Do not allow the user to edit the text in the control.
ES_RIGHT
Right-align the text.
ES_UPPERCASE
Convert all the characters to uppercase as they are typed.
ES_WANTRETURN
Insert a carriage return into a multi-line edit control when the user pressed ENTER, instead of implementing the default behavior of ENTER.

List Box Control Styles

The following window styles can only be used by list box controls -- windows created out of window class "LISTBOX".

LBS_DISABLENOSCROLL
Show a disable the vertical scroll bar in the list box if it does not contain enough items to scroll. If this flag is not specified, such a scroll bar is not displayed.
LBS_EXTENDEDSEL
Allow the user to select multiple items.
LBS_HASSTRINGS
The list box is drawn manually by the application and contains strings. Either LBS_OWNERDRAWFICED or LBS_OWNERDRAWVARIABLE must also be specified.
LBS_MULTICOLUMN
The list box contains multiple columns which are scrolled horizontally.
LBS_MULTIPLESEL
Toggle the selection of a string every time the user clicks or double-clicks it.
LBS_NODATA
Intended for list boxes having more than 1000 items, do not have the operating system handle any of the entries. LBS_OWNERDRAWFIXED must also be specified, and neither LBS_SORT nor LBS_HASSTRINGS can be specified.
LBS_NOINTEGRALHEIGHT
Force the list box to be exactly the size specified by the application, instead of allowing the operating system to slightly resize it to prevent displaying partial selections.
LBS_NOREDRAW
Do not redraw the list box when changes are made.
LBS_NOSEL
Do not allow the user to select items in the list box.
LBS_NOTIFY
Notify the parent window whenever the user clicks or double-clicks a string in the list box.
LBS_OWNERDRAWFIXED
The owner of the list box is fully responsible for drawing it manually, and all of the items in the list box have the same height.
LBS_OWNERDRAWVARIABLE
The owner of the list box is full responsible for drawing it manually, and the heights of the items in the list box have can be different.
LBS_SORT
Automatically sort the strings in the list box alphabetically.
LBS_STANDARD
Automatically sort the strings in the list box alphabetically, notify the parent window whenever the user clicks or double-clicks a string, and display a border around the list box.
LBS_USETABSTOPS
Allow the list box to expand tab characters when drawing its strings.
LBS_WANTKEYBOARDINPUT
Notify the owner of the list box whenever the user types a key while the list box has the focus.

Scroll Bar Control Styles

The following window styles can only be used by scroll bar controls -- windows created out of window class "SCROLLBAR".

SBS_BOTTOMALIGM
Align the bottom edge of the scroll bar with the bottom edge of its rectangle, using its default height. SBS_HORZ must also be specified.
SBS_HORZ
The scroll bar is a horizontal scroll bar.
SBS_LEFTALIGN
Align the left edge of the scroll bar with the left edge of its rectangle, using its default width. SBS_VERT must also be specified.
SBS_RIGHTALIGN
Align the right edge of the scroll bar with the right edge of its rectangle, using its default width. SBS_VERT must also be specified.
SBS_SIZEBOX
The scroll bar is a size box.
SBS_SIZEBOXBOTTOMRIGHTALIGN
Align the lower-right corner of the size box with the lower-right corner of its rectangle, using its default width and height. SBS_SIZEBOX must also be specified.
SBS_SIZEBOXTOPLEFTALIGN
Align the upper-left corner of the size box with the upper-left corner of its rectangle, using its default width and hieght. SBS_SIZEBOX must also be specified.
SBS_SIZEGRIP
The scroll bar is a size box with a raised edge.
SBS_TOPALIGN
Align the top edge of the scroll bar with the top edge of its rectangle, using its default height. SBS_HORZ must also be specified.
SBS_VERT
The scroll bar is a vertical scroll bar.

Static Control Styles

The following window styles can only be used by static controls -- windows created out of window class "STATIC".

SS_BITMAP
Display the bitmap specified by the static control's text.
SS_BLACKFRAME
Draw a frame around the static control in the same color as a window frame.
SS_BLACKRECT
Fill the static control with the same color as a window frame.
SS_CENTER
Center the text in the static control.
SS_CENTERIMAGE
If the bitmap or icon is smaller than the size of the static control, fill the rest of the control with whatever color is at the image's upper-left corner.
SS_ENDELLIPSIS
Windows NT, 2000: Replace the end of the string with an ellipsis if it is too long to fit in the static control.
SS_ENHMETAFILE
Display the enhanced metafile identified by the static control's text. Scale the enhanced metafile to fit the static control.
SS_ETCHEDFRAME
Draw the frame of the static control using the etched edge style.
SS_ETCHEDHORZ
Draw only the top and bottom edges of the static control using the etched edge style.
SS_ETCHEDVERT
Draw only the left and right edges of the static control using the etched edge style.
SS_GRAYFRAME
Draw a frame around the static control in the same color as the screen background.
SS_GRAYRECT
Fill the static control with the same color as the screen background.
SS_ICON
Display the icon identified by the static control's text. The static control automatically resizes to the size of the icon.
SS_LEFT
Left-align the text in the static control.
SS_LEFTNOWORDWRAP
Left-align the text in the static control, but do not word wrap.
SS_NOPREFIX
Do not use an amperstand character in the string to identify an accelerator prefix, instead displaying the amperstands as regular characters.
SS_OWNERDRAW
The owner of the static control is fully responsible for drawing the control.
SS_PATHELLIPSIS
Windows NT, 2000: Replace characters in the middle of a string holding a path with an ellipsis if it is too long to fit in the static control.
SS_REALSIZEIMAGE
Clip an image or bitmap if it does not fit inside the static control instead of resizing the control.
SS_RIGHT
Right-align the text in the static control.
SS_RIGHTJUST
Do not move the lower-right corner of the static control when resizing it to accomodate a bitmap or icon.
SS_SIMPLE
Draw a simple rectangle and display a single line of left-aligned text in the static control.
SS_SUNKEN
Draw a half-sunken border around the static control.
SS_WHITEFRAME
Draw a frame around the static control in the same color as the window background.
SS_WHITERECT
Fill the static control with the same color as the window background.
SS_WORDELLIPSIS
Windows NT, 2000: Truncate text and add ellipses to text which does not fit into the static control.

Constant Definitions

Const WS_BORDER = &H800000
Const WS_CAPTION = &HC00000
Const WS_CHILD = &H40000000
Const WS_CHILDWINDOW = &H40000000
Const WS_CLIPCHILDREN = &H2000000
Const WS_CLIPSIBLINGS = &H4000000
Const WS_DISABLED = &H8000000
Const WS_DLGFRAME = &H400000
Const WS_GROUP = &H20000
Const WS_HSCROLL = &H100000
Const WS_ICONIC = &H20000000
Const WS_MAXIMIZE = &H1000000
Const WS_MAXIMIZEBOX = &H10000
Const WS_MINIMIZE = &H20000000
Const WS_MINIMIZEBOX = &H20000
Const WS_OVERLAPPED = &H0
Const WS_OVERLAPPEDWINDOW = &HCF0000
Const WS_POPUP = &H80000000
Const WS_POPUPWINDOW = &H80880000
Const WS_SIZEBOX = &H40000
Const WS_SYSMENU = &H80000
Const WS_TABSTOP = &H10000
Const WS_THICKFRAME = &H40000
Const WS_TILED = &H0
Const WS_TILEDWINDOW = &HCF0000
Const WS_VISIBLE = &H10000000
Const WS_VSCROLL = &H200000
Const BS_3STATE = &H5
Const BS_AUTO3STATE = &H6
Const BS_AUTOCHECKBOX = &H3
Const BS_AUTORADIOBOX = &H9
Const BS_BITMAP = &H80
Const BS_BOTTOM = &H800
Const BS_CENTER = &H300
Const BS_CHECKBOX = &H2
Const BS_DEFPUSHBUTTON = &H1
Const BS_FLAT = &H8000
Const BS_GROUPBOX = &H7
Const BS_ICON = &H40
Const BS_LEFT = &H100
Const BS_LEFTTEXT = &H20
Const BS_MULTILINE = &H2000
Const BS_NOTIFY = &H4000
Const BS_OWNERDRAW = &HB
Const BS_PUSHBUTTON = &H0
Const BS_PUSHLIKE = &H1000
Const BS_RADIOBUTTON = &H4
Const BS_RIGHT = &H200
Const BS_RIGHTBUTTON = &H20
Const BS_TEXT = &H0
Const BS_TOP = &H400
Const BS_USERBUTTON = &H8
Const BS_VCENTER = &HC00
Const CBS_AUTOHSCROLL = &H40
Const CBS_DISABLENOSCROLL = &H800
Const CBS_DROPDOWN = &H2
Const CBS_DROPDOWNLIST = &H3
Const CBS_HASSTRINGS = &H200
Const CBS_LOWERCASE = &H4000
Const CBS_NOINTEGRALHEIGHT = &H400
Const CBS_OEMCONVERT = &H80
Const CBS_OWNERDRAWFIXED = &H10
Const CBS_OWNERDRAWVARIABLE = &H20
Const CBS_SIMPLE = &H1
Const CBS_SORT = &H100
Const CBS_UPPERCASE = &H2000
Const ES_AUTOHSCROLL = &H80
Const ES_AUTOVSCROLL = &H40
Const ES_CENTER = &H1
Const ES_LEFT = &H0
Const ES_LOWERCASE = &H10
Const ES_MULTILINE = &H4
Const ES_NOHIDESEL = &H100
Const ES_NUMBER = &H2000
Const ES_OEMCONVERT = &H400
Const ES_PASSWORD = &H20
Const ES_READONLY = &H800
Const ES_RIGHT = &H2
Const ES_UPPERCASE = &H8
Const ES_WANTRETURN = &H1000
Const LBS_DISABLENOSCROLL = &H1000
Const LBS_EXTENDEDSEL = &H800
Const LBS_HASSTRINGS = &H40
Const LBS_MULTICOLUMN = &H200
Const LBS_MULTIPLESEL = &H8
Const LBS_NODATA = &H2000
Const LBS_NOINTEGRALHEIGHT = &H100
Const LBS_NOREDRAW = &H4
Const LBS_NOSEL = &H4000
Const LBS_NOTIFY = &H1
Const LBS_OWNERDRAWFIXED = &H10
Const LBS_OWNERDRAWVARIABLE = &H20
Const LBS_SORT = &H2
Const LBS_STANDARD = &HA00006
Const LBS_USETABSTOPS = &H80
Const LBS_WANTKEYBOARDINPUT = &H400
Const SBS_BOTTOMALIGN = &H4
Const SBS_HORZ = &H0
Const SBS_LEFTALIGN = &H2
Const SBS_RIGHTALIGN = &H4
Const SBS_SIZEBOX = &H8
Const SBS_SIZEBOXBOTTOMRIGHTALIGN = &H4
Const SBS_SIZEBOXTOPLEFTALIGN = &H2
Const SBS_SIZEGRIP = &H10
Const SBS_TOPALIGN = &H2
Const SBS_VERT = &H1
Const SS_BITMAP = &HE
Const SS_BLACKFRAME = &H7
Const SS_BLACKRECT = &H4
Const SS_CENTER = &H1
Const SS_CENTERIMAGE = &H200
' Const SS_ENDELLIPSIS = ???
Const SS_ENHMETAFILE = &HF
Const SS_ETCHEDFRAME = &H12
Const SS_ETCHEDHORZ = &H10
Const SS_ETCHEDVERT = &H11
Const SS_GRAYFRAME = &H8
Const SS_GRAYRECT = &H5
Const SS_ICON = &H3
Const SS_LEFT = &H0
Const SS_LEFTNOWORDWRAP = &HC
Const SS_NOPREFIX = &H80
Const SS_NOTIFY = &H100
Const SS_OWNERDRAW = &HD
' Const SS_PATHELLIPSIS = ???
Const SS_REALSIZEIMAGE = &H800
Const SS_RIGHT = &H2
Const SS_RIGHTJUST = &H400
Const SS_SIMPLE = &HB
Const SS_SUNKEN = &H1000
Const SS_WHITEFRAME = &H9
Const SS_WHITERECT = &H6
' Const SS_WORDELLIPSIS = ???

Used By

GetClassLong, GetWindowLong, SetClassLong, SetWindowLong

Back to the index.


Last Modified: August 27, 1999
This page is copyright © 1999 Paul Kuliniewicz. Copyright Information

Go to Paul Kuliniewicz's Home Page.
E-mail: rogue953@hotmail.com
This page is at http://skyscraper.fortunecity.com/transmission/45/api/other/windowstyles.html