gui 7.55 KB
Newer Older
1 2 3 4 5
My tests show that Windows window management events behave like described
in this file, at least under Win98.
The (16/32) or (16) or (32) at the end shows whether the sequence has been
confirmed for win16, win32, or both.

Ove Kaaven's avatar
Ove Kaaven committed
6
Window Edge Styles (Win31 look), in order of precedence:
7 8
 WS_EX_DLGMODALFRAME: double border, WS_CAPTION allowed
 WS_THICKFRAME: thick border
Ove Kaaven's avatar
Ove Kaaven committed
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
 WS_DLGFRAME: double border, WS_CAPTION not allowed (but possibly shown anyway, untested)
 WS_BORDER (default for overlapped windows): single black border
 none (default for child and popup windows): no border

Window Edge Styles (Win95/98 look), in order of precedence:
 WS_EX_DLGMODALFRAME: double border, WS_CAPTION allowed
 WS_THICKFRAME: thick border
 WS_DLGFRAME: double border, WS_CAPTION not allowed (but possibly shown anyway)
 WS_BORDER (default for overlapped windows): single black border
 none (default for child (and popup?) windows): no border

Win31 look, system metrics relations:
 CYFRAME    = 5, thick border, includes both edges (the colored inside is thus 3 pixels)
 CYDLGFRAME = 4, double border
 CYBORDER   = 1, thin border
 CYCAPTION  = 20, includes both borders (the colored inside is thus 18 pixels)
 CYMENU     = 18, does not include any borders
 CYHSCROLL  = 17, includes both borders (the colored inside is thus 15 pixels)
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71

CreateWindow (for overlapped window, not initially visible) (16/32)
Messages sent:
 WM_GETMINMAXINFO
 WM_NCCREATE
 WM_NCCALCSIZE (wParam=0)
 WM_CREATE

ShowWindow (for overlapped window) (16/32)
Messages sent:
 WM_SHOWWINDOW (wParam=1)
 WM_WINDOWPOSCHANGING (NOMOVE|NOSIZE|SHOWWINDOW)
 WM_QUERYNEWPALETTE, if in 256-color mode
 WM_WINDOWPOSCHANGING (NOMOVE|NOSIZE)
 WM_ACTIVATEAPP (wParam=1)
 WM_NCACTIVATE (wParam=1)
  DefWindowProc:
   WM_GETTEXT
 WM_ACTIVATE (wParam=1)
  DefWindowProc:
   WM_SETFOCUS (wParam=0)
 WM_NCPAINT (wParam=1)
  DefWindowProc:
   WM_GETTEXT
 WM_ERASEBKGND
 WM_WINDOWPOSCHANGED (NOMOVE|NOSIZE|NOZORDER|SHOWWINDOW)
 WM_SIZE (NOT from DefWindowProc)
 WM_MOVE (NOT from DefWindowProc)

(WM_NCHITTEST and WM_SETCURSOR will tend to follow immediately after the
 ShowWindow if the mouse is inside the window)

DestroyWindow (for overlapped window) (32)
Messages sent:
 WM_WINDOWPOSCHANGING (wParam=0)
 WM_WINDOWPOSCHANGED (wParam=0)
 WM_NCACTIVATE (wParam=0)
 WM_ACTIVATE (wParam=0)
 WM_ACTIVATEAPP (wParam=0)
 WM_KILLFOCUS (wParam=0)
 WM_DESTROY
 WM_NCDESTROY

CreateWindow (for child window, not initially visible)
Messages sent:
Ove Kaaven's avatar
Ove Kaaven committed
72 73
 WM_NCCREATE
 (child is inserted into parent's child list after WM_NCCREATE returns)
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268
 WM_NCCALCSIZE (wParam=0)
 WM_CREATE
 WM_SIZE
 WM_MOVE
 (to parent window) WM_PARENTNOTIFY (wParam=1)

ShowWindow (for child window)
Messages sent:
 WM_SHOWWINDOW (wParam=1)
 WM_WINDOWPOSCHANGING (wParam=0)
 (to parent window) WM_ERASEBKGND
 WM_WINDOWPOSCHANGED (wParam=0)

DestroyWindow (for child window)
Messages sent:
 (to parent window) WM_PARENTNOTIFY (wParam=2)
 WM_SHOWWINDOW (wParam=0)
 WM_WINDOWPOSCHANGING (wParam=0)
 (to parent window) WM_ERASEBKGND
 WM_WINDOWPOSCHANGED (wParam=0)
 WM_DESTROY
 WM_NCDESTROY

Moving the mouse:
Messages sent:
 WM_NCHITTEST
 WM_SETCURSOR
Messages posted:
 WM_MOUSEMOVE, if WM_NCHITTEST returns HTCLIENT
 WM_NCMOUSEMOVE, if WM_NCHITTEST returns somewhere in nonclient area (not HTNOWHERE)

Moving by dragging the title bar (after WM_NCHITTEST and WM_SETCURSOR) (outline move):
 WM_NCLBUTTONDOWN (wParam=2=HTCAPTION)
  DefWindowProc:
   WM_SYSCOMMAND (wParam=0xf012=SC_MOVE+2)
    DefWindowProc:
     WM_GETMINMAXINFO
     WM_ENTERSIZEMOVE
     WM_WINDOWPOSCHANGING
     WM_WINDOWPOSCHANGED
      DefWindowProc:
       WM_MOVE
     WM_EXITSIZEMOVE

Sizing by dragging the thick borders (after WM_NCHITTEST and WM_SETCURSOR) (outline move):
 WM_NCLBUTTONDOWN (wParam=0xd)
  DefWindowProc:
   WM_SYSCOMMAND (wParam=0xf004)
    DefWindowProc:
     WM_GETMINMAXINFO
     WM_ENTERSIZEMOVE
     WM_SIZING (wParam=4) (many times, probably one for each mouse movement)
     WM_WINDOWPOSCHANGING
      DefWindowProc:
       WM_GETMINMAXINFO
     WM_NCCALCSIZE (wParam=1)
     WM_NCPAINT (wParam=1)
      DefWindowProc:
       WM_GETTEXT
     WM_ERASEBKGND
     WM_WINDOWPOSCHANGED
      DefWindowProc:
       WM_MOVE
       WM_SIZE
     WM_EXITSIZEMOVE

Resizing child window with MoveWindow (32):
 WM_WINDOWPOSCHANGING
 WM_NCCALCSIZE (wParam=1)
 WM_ERASEBKGND
 WM_WINDOWPOSCHANGED
  DefWindowProc:
   WM_MOVE
   WM_SIZE

Clicking on inactive button:
Messages sent:
 WM_NCHITTEST
 (to parent window) WM_PARENTNOTIFY (wParam=0x201=WM_LBUTTONDOWN)
 WM_MOUSEACTIVATE
  ButtonProc->DefWindowProc:
   (to parent window) WM_MOUSEACTIVATE
 WM_SETCURSOR
  ButtonProc->DefWindowProc:
   (to parent window) WM_SETCURSOR
Messages posted:
 WM_LBUTTONDOWN
  (to parent window) WM_KILLFOCUS
  WM_SETFOCUS
   (to parent window) WM_CTLCOLORBTN
  BM_SETSTATE32
   (to parent window) WM_CTLCOLORBTN
 WM_LBUTTONUP
  BM_SETSTATE32
   (to parent window) WM_CTLCOLORBTN
  (to parent window) WM_COMMAND

Reparenting a button (16/32):
 WM_SHOWWINDOW (wParam=0)
 WM_WINDOWPOSCHANGING (HIDEWINDOW|NOACTIVATE|NOMOVE|NOSIZE|NOZORDER)
 (to parent window) WM_ERASEBKGND
 WM_WINDOWPOSCHANGED (HIDEWINDOW|NOACTIVATE|NOMOVE|NOSIZE|NOZORDER)
 WM_WINDOWPOSCHANGING (NOSIZE|NOZORDER)
 WM_CHILDACTIVATE
 WM_WINDOWPOSCHANGED (NOSIZE|NOREDRAW|NOZORDER)
  DefWindowProc:
   WM_MOVE
 WM_SHOWWINDOW (wParam=1)
The last child (button) reparented gets topmost for its new parent.

Creation of a modal dialog (32):
 (to parent window) WM_CANCELMODE
 (to parent window) WM_KILLFOCUS
 (to parent window) WM_ENABLE (wParam=0)
 (window proc creation messages not tracked yet, because...)
 (dlgproc) WM_SETFONT
 (dlgproc) WM_INITDIALOG
 (...the window proc message hook was installed here, IsVisible still FALSE)
 (to parent window) WM_NCACTIVATE (wParam=0)
  DefWindowProc:
   WM_GETTEXT
 (to parent window) WM_ACTIVATE (wParam=0)
 WM_WINDOWPOSCHANGING
 (to parent window) WM_WINDOWPOSCHANGING
 WM_NCACTIVATE (wParam=1)
 WM_ACTIVATE (wParam=1)
 (setting focus)
 WM_SHOWWINDOW (wParam=1)
 WM_WINDOWPOSCHANGING
 WM_NCPAINT
  DefWindowProc:
   WM_GETTEXT
 WM_ERASEBKGND
  DialogWindowProc(?):
   WM_CTLCOLORDLG
 WM_WINDOWPOSCHANGED
 WM_PAINT
 (bunch of WM_CTLCOLOR* for each control)
 (to parent window) WM_PAINT
 (to parent window) WM_ENTERIDLE (wParam=0)
 (to parent window) WM_SETCURSOR

Destruction of a modal dialog (32):
 (inside dialog proc: EndDialog is called)
  (to parent window) WM_ENABLE (wParam=1)
  WM_SETFOCUS
  WM_WINDOWPOSCHANGING
  (to parent window) WM_NCPAINT
   DefWindowProc:
    WM_GETTEXT
  (to parent window) WM_ERASEBKGND
  WM_WINDOWPOSCHANGED
  WM_NCACTIVATE (wParam=0)
  WM_ACTIVATE (wParam=0)
  WM_WINDOWPOSCHANGING
  (to parent window) WM_WINDOWPOSCHANGING
  (to parent window) WM_NCACTIVATE (wParam=1)
   DefWindowProc:
    WM_GETTEXT
  (to parent window) WM_ACTIVATE (wParam=1)
   (to dialog) WM_KILLFOCUS
   (to parent window) WM_SETFOCUS
 WM_DESTROY
 WM_NCDESTROY

Creation of a modal dialog that is resized inside WM_INITDIALOG (32):
 (inside dialog proc, handling WM_INITDIALOG)
  WM_WINDOWPOSCHANGING
  WM_NCCALCSIZE
  (to parent window) WM_NCACTIVATE (wParam=0)
   DefWindowProc:
    WM_GETTEXT
  (to parent window) WM_ACTIVATE (wParam=0)
  WM_WINDOWPOSCHANGING
  (to parent window) WM_WINDOWPOSCHANGING
  WM_NCACTIVATE (wParam=1)
  WM_ACTIVATE (wParam=1)
  WM_WINDOWPOSCHANGED
   DefWindowProc:
    WM_SIZE
 (setting focus)
 WM_SHOWWINDOW (wParam=1)
 WM_WINDOWPOSCHANGING
 WM_NCPAINT
  DefWindowProc:
   WM_GETTEXT
 WM_ERASEBKGND
  DialogWindowProc(?):
   WM_CTLCOLORDLG
 WM_WINDOWPOSCHANGED
 WM_PAINT
 (bunch of WM_CTLCOLOR* for each control)
 (to parent window) WM_PAINT
 (to parent window) WM_ENTERIDLE (wParam=0)
 (to parent window) WM_SETCURSOR