Window State

The WND structure has from the start provided a set of bit fields in union with the state member as a ULONG. Microsoft’s names and definitions are known from symbol files for WIN32K.SYS from Windows 7 only.

The USEREXTS and USERKDX debugger extensions, as supplied in the Device Driver Kit (DDK) for Windows NT 3.51 through to Windows 2000 but apparently not since, have names that likely reproduce macros from Microsoft’s headers. These name a sort of index into the set of window flags that comprises the state, state2, ExStyle and style members considered as an array of bytes. The high byte in each such 16-bit index is the byte offset to the bit and the low byte is the bit mask within that byte.

All but half a dozen of these 32 bit fields are well-defined through the whole history of Windows—and those few changes are from as long ago as Windows 2000.

Mask Index Bit Field Definition Window Flag Name Versions Remarks
0x00000001 0x0001
INT bHasMeun : 1;
WFMPRESENT all  
0x00000002 0x0002
INT bHasVerticalScrollbar : 1;
WFVPRESENT all  
0x00000004 0x0004
INT bHasHorizontalScrollbar : 1;
WFHPRESENT all  
0x00000008 0x0008
INT bHasCaption : 1;
WFCPRESENT all  
0x00000010 0x0010
INT bSendSizeMoveMsgs : 1;
WFSENDSIZEMOVE all  
0x00000020 0x0020   WFNOPAINT see note  
INT bMsgBox : 1;
WFMSGBOX 5.0 and higher  
0x00000040 0x0040
INT bActiveFrame : 1;
WFFRAMEON all  
0x00000080 0x0080
INT bHasSPB : 1;
WFHASSPB all  
0x00000100 0x0101
INT bNoNCPaint : 1;
WFNONCPAINT all  
0x00000200 0x0102
INT bSendEraseBackground : 1;
WFSENDERASEBKGND all  
0x00000400 0x0104
INT bEraseBackground : 1;
WFERASEBKGND all  
0x00000800 0x0108
INT bSendNCPaint : 1;
WFSENDNCPAINT all  
0x00001000 0x0110
INT bInternalPaint : 1;
WFINTERNALPAINT all  
0x00002000 0x0120
INT bUpdateDirty : 1;
WFUPDATEDIRTY all  
0x00004000 0x0140
INT bHiddenPopup : 1;
WFHIDDENPOPUP all  
0x00008000 0x0180
INT bForceMenuDraw : 1;
WFMENUDRAW all  
0x00010000 0x0201
INT bDialogWindow : 1;
WFDIALOGWINDOW all  
0x00020000 0x0202
INT bHasCreatestructName : 1;
WFTITLESET all  
0x00040000 0x0204
INT bServerSideWindowProc : 1;
WFSERVERSIDEPROC all  
0x00080000 0x0208
INT bAnsiWindowProc : 1;
WFANSIPROC all  
0x00100000 0x0210   WF16BIT
see note  
INT bBeingActivated : 1;
WFBEINGACTIVATED 5.0 and higher previously 0x00000200 in state2
0x00200000 0x0220
INT bHasPalette : 1;
WFHASPALETTE all  
0x00400000 0x0240
INT bPaintNotProcessed : 1;
WFPAINTNOTPROCESSED all  
0x00800000 0x0280   WFWIN31COMPAT 3.10 to 4.0 next as 0x00000100 in state2
INT bSyncPaintPending : 1;
WFSYNCPAINTPENDING 5.0 and higher previously 0x00000100 in state2
0x01000000 0x0301   WFALWAYSSENDNCPAINT 3.10 to 4.0 next as 0x00400000 in state2
INT bRecievedQuerySuspendMsg : 1;
WFGOTQUERYSUSPENDMSG 5.0 and higher  
0x02000000 0x0302   WFPIXIEHACK 3.10 to 4.0 next as 0x00800000 in state2
INT bRecievedSuspendMsg : 1;
WFGOTSUSPENDMSG 5.0 and higher  
0x04000000 0x0304
INT bToggleTopmost : 1;
WFTOGGLETOPMOST all  
0x08000000 0x0308
INT bRedrawIfHung : 1;
WFREDRAWIFHUNG all  
0x10000000 0x0310
INT bRedrawFrameIfHung : 1;
WFREDRAWFRAMEIFHUNG all  
  0x0318   WFANYHUNGREDRAW see note  
0x20000000 0x0320
INT bAnsiCreator : 1;
WFANSICREATOR all  
0x40000000 0x0340   WFPALETTEWINDOW see note  
INT bMaximizesToMonitor : 1;
WFREALLYMAXIMIZABLE 5.0 and higher  
0x80000000 0x0380
INT bDestroyed : 1;
WFDESTROYED all  

The mis-spellings bHasMeun, bRecievedQuerySuspendMsg and bRecievedSuspendMsg are Microsoft’s.

The first four flags, along with the later addition bHasClientEdge in state2, are recalculated whenever the window’s client rectangle is recalculated.

The bSendSizeMoveMsgs flag is set when a window is created but has neither the WS_CHILD nor WS_POPUP styles. Such a window is not sent WM_SIZE and WM_MOVE messages while being created. These messages are instead deferred until the first ShowWindow (which clears the flag).

Debugger extensions for both Windows NT 3.51 and 4.0 have WFNOPAINT for the 16-bit encoding that corresponds to the state mask 0x00000020. I know of no reason to disbelieve this name but neither do I know of any use of this bit field before version 5.0 evidently repurposed it. The same applies also to the 0x00100000 and 0x40000000 flags, whose encodings the debugger extensions name as WF16BIT and WFPALETTEWINDOW in the early versions.

Debugger extensions for both Windows NT 4.0 and Windows 2000 define WFANYHUNGREDRAW for the combination of closely related bit fields bRedrawIfHung and bRedrawFrameIfHung. Presumably, it is used—but if so, the only known use has the constant optimised away when testing whether either bit is set. If that is the only use, then it dates from version 3.51, no matter that the debugger extension for Windows NT 3.51 omits it.