Microsoft KB Archive/83366

{|
 * width="100%"|

INFO: Value Returned by GetWindowLong(hWnd, GWL_STYLE)

 * }

Q83366

-

The information in this article applies to:


 * Microsoft Win32 Software Development Kit (SDK), used with:
 * Microsoft Windows 95
 * the operating system: Microsoft Windows NT, versions 3.5, 3.51
 * the operating system: Microsoft Windows 2000
 * Microsoft Windows Software Development Kit (SDK) 3.1

-

SUMMARY
GetWindowLong(hWnd, GWL_STYLE) returns the window style information stored at the GWL_STYLE offset of the window data structure identified by hWnd. This offset contains the current state of the window, rather than the style specified when the window was created.

Windows can set and clear the following styles over the lifetime of a window: WS_CLIPSIBLINGS, WS_DISABLED, WS_HSCROLL, WS_MAXIMIZE, WS_MINIMIZE, WS_SYSMENU (for MDI child windows), WS_THICKFRAME, WS_VISIBLE, and WS_VSCROLL. Windows will not dynamically set or clear any of the other styles. An application can modify the style state at the GWL_STYLE offset at any time by calling SetWindowLong(hWnd, GWL_STYLE, dwNewLong), but Windows will not be aware that the style has changed. Windows maintains some internal flags on the window style and may use these rather than checking the GWL_STYLE offset of the window data structure.

GetWindowLong(hWnd, GWL_STYLE) returns a LONG value, which contains the currently active styles combined by the Boolean OR operator. An application can change the information stored at the GWL_STYLE offset by calling SetWindowLong(hWnd, GWL_STYLE, dwNewLong).

MORE INFORMATION
The following table lists the windows styles that Windows updates throughout the life span of a window. In the Change column below, an &quot;S&quot; indicates that the style is set and a &quot;C&quot; indicates that the style is cleared. The Where column lists the source module involved. Windows will change a window's styles as follows:

  Style       Change  Window      Where       Why WS_CLIPSIBLINGS

S      Overlapped  WMCREATE.C  Set on creation.

WS_CLIPSIBLINGS

S      Popup       WMCREATE.C  Set on creation.

WS_DISABLED S & C  Any         WMACT.C     Set or cleared when EnableWindow function disables or enables window.

WS_HSCROLL S & C   SB_HORZ     WINSBCTL.C  Set or cleared as scroll bar range changed (for                                              window scroll bar, not the                                               SCROLL BAR class).

WS_HSCROLL S & C   SB_HORZ     SBRARE.C    Set or cleared in                                               ShowScrollBar (for window                                               scroll bar, not the SCROLL                                               BAR class).

WS_HSCROLL S & C   List boxes  LBOXCTL1.C  Set if scroll bar required to see contents.

WS_HSCROLL S & C   MDI frame   MDIWIN.C    Set if required to see children.

WS_MAXIMIZE C      Any         WMCREATE.C  On creation (reset                                               immediately in                                               WMMINMAX.C).

WS_MAXIMIZE C      Any         WMMOVE.C    Cleared if window resized.

WS_MAXIMIZE S & C  Any         WMMINMAX.C  Set if window maximized, cleared if no longer maximized.

WS_MINIMIZE C      Any         WMCREATE.C  On creation (reset                                               immediately in                                               WMMINMAX.C).

WS_MINIMIZE C      Any         WMMOVE.C    Cleared if window resized.

WS_MINIMIZE S & C  any         WMMINMAX.C  Set if window minimized, cleared if no longer minimized.

WS_SYSMENU S & C   MDI child   MDIMENU.C   Cleared if child is                                               maximized and uses frame menu. Set when child no                                              longer maximized. WS_THICKFRAME S & C  Any         WINSBCTL.C  State changed for only a                                               few instructions during painting.

WS_VISIBLE C       Any         WMCREATE.C  Cleared and then reset by                                               call to ShowWindow.

WS_VISIBLE S & C   Any         WMSHOW.C    Cleared if window hidden in ShowWindow, set if                                              shown.

WS_VISIBLE S & C   Any         WMSWP.C     Cleared if window hidden in ShowWindow, set if                                              shown.

WS_VISIBLE C       MDI client  MDIWIN.C    Cleared when current MDI child is maximized, and new child is activated. Immediately reset with call to ShowWindow.

WS_VISIBLE S       Desktop     INLOADW.C   Ensure desktop visible.

WS_VISIBLE S & C   Any         MSDWP.C     Set or cleared when DefWindowProc receives WM_SETREDRAW message to                                              turn drawing on or off, respectively.

WS_VISIBLE S & C   MDI client  MDIWIN.C    Cleared and then immediately reset to                                              optimize painting.

WS_VSCROLL S & C   SB_VERT     WINSBCTL.C  Set or cleared as scroll bar range changed (for                                              window scroll bar, not the                                               SCROLL BAR class).

WS_VSCROLL S & C   List boxes  LBOXCTL1.C  Set if scroll bar required to see entire contents.

WS_VSCROLL S & C   MDI frame   MDIWIN.C    Set if required to see children.

WS_VSCROLL S & C   SB_VERT     SBRARE.C    Set/cleared in                                               ShowScrollBar (for window                                               scroll bar, not the SCROLL                                               BAR class). In addition to the information above, the GetWindowLong function always reports some style bits to be clear, as follows:


 * Combo boxes always report the following styles as clear:

CBS_HASSTRINGS, CBS_SORT, WS_BORDER, WS_HSCROLL, and WS_VSCROLL
 * All edit controls report the WS_BORDER style clear.
 * Multiline edit controls report the WS_HSCROLL style clear if the control contains centered or right-justified text.

Additional query words:

Keywords : kbOSWinNT350 kbOSWinNT351 kbOSWin2000 kbSDKWin32 kbGrpDSUser kbOSWin310 kbOSWin95 kbWndw kbWndwProp kbOSWin300

Issue type : kbinfo

Technology : kbWin32SDKSearch kbAudDeveloper kbSDKSearch kbWin32sSearch