ReactOS  0.4.15-dev-5615-gc3644fd
nonclient.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS Win32k subsystem
4  * PURPOSE: Miscellaneous User functions
5  * FILE: win32ss/user/ntuser/nonclient.c
6  * PROGRAMER:
7  */
8 
9 #include <win32k.h>
10 #include <windowsx.h>
11 
12 DBG_DEFAULT_CHANNEL(UserDefwnd);
13 
14 #define UserHasDlgFrameStyle(Style, ExStyle) \
15  (((ExStyle) & WS_EX_DLGMODALFRAME) || \
16  (((Style) & WS_DLGFRAME) && (!((Style) & WS_THICKFRAME))))
17 
18 #define UserHasThickFrameStyle(Style, ExStyle) \
19  (((Style) & WS_THICKFRAME) && \
20  (!(((Style) & (WS_DLGFRAME | WS_BORDER)) == WS_DLGFRAME)))
21 
22 #define UserHasThinFrameStyle(Style, ExStyle) \
23  (((Style) & WS_BORDER) || (!((Style) & (WS_CHILD | WS_POPUP))))
24 
25 #define ON_LEFT_BORDER(hit) \
26  (((hit) == HTLEFT) || ((hit) == HTTOPLEFT) || ((hit) == HTBOTTOMLEFT))
27 #define ON_RIGHT_BORDER(hit) \
28  (((hit) == HTRIGHT) || ((hit) == HTTOPRIGHT) || ((hit) == HTBOTTOMRIGHT))
29 #define ON_TOP_BORDER(hit) \
30  (((hit) == HTTOP) || ((hit) == HTTOPLEFT) || ((hit) == HTTOPRIGHT))
31 #define ON_BOTTOM_BORDER(hit) \
32  (((hit) == HTBOTTOM) || ((hit) == HTBOTTOMLEFT) || ((hit) == HTBOTTOMRIGHT))
33 
34 #define HASSIZEGRIP(Style, ExStyle, ParentStyle, WindowRect, ParentClientRect) \
35  ((!(Style & WS_CHILD) && (Style & WS_THICKFRAME) && !(Style & WS_MAXIMIZE)) || \
36  ((Style & WS_CHILD) && (ParentStyle & WS_THICKFRAME) && !(ParentStyle & WS_MAXIMIZE) && \
37  (WindowRect.right - WindowRect.left == ParentClientRect.right) && \
38  (WindowRect.bottom - WindowRect.top == ParentClientRect.bottom)))
39 
40 
43  RECTL *rect,
44  ULONG width,
45  ULONG height)
46 {
47  HBRUSH hbrush = NtGdiSelectBrush( hdc, gpsi->hbrGray );
48  NtGdiPatBlt( hdc, rect->left, rect->top, rect->right - rect->left - width, height, PATINVERT );
49  NtGdiPatBlt( hdc, rect->left, rect->top + height, width, rect->bottom - rect->top - height, PATINVERT );
50  NtGdiPatBlt( hdc, rect->left + width, rect->bottom - 1, rect->right - rect->left - width, -(LONG)height, PATINVERT );
51  NtGdiPatBlt( hdc, rect->right - 1, rect->top, -(LONG)width, rect->bottom - rect->top - height, PATINVERT );
53 }
54 
57  RECTL *rect,
58  BOOL thickframe)
59 {
61  else UserDrawWindowFrame(hdc, rect, 1, 1);
62 }
63 
64 /***********************************************************************
65  * NC_GetInsideRect
66  *
67  * Get the 'inside' rectangle of a window, i.e. the whole window rectangle
68  * but without the borders (if any).
69  */
70 void FASTCALL // Previously known as "UserGetInsideRectNC"
72 {
73  ULONG Style;
74  ULONG ExStyle;
75 
76  Style = Wnd->style;
77  ExStyle = Wnd->ExStyle;
78 
79  rect->top = rect->left = 0;
80  rect->right = Wnd->rcWindow.right - Wnd->rcWindow.left;
81  rect->bottom = Wnd->rcWindow.bottom - Wnd->rcWindow.top;
82 
83  if (Style & WS_ICONIC) return;
84 
85  /* Remove frame from rectangle */
87  {
89  }
91  {
93  /* FIXME: this isn't in NC_AdjustRect? why not? */
95  RECTL_vInflateRect( rect, -1, 0 );
96  }
98  {
100  }
101 
102  /* We have additional border information if the window
103  * is a child (but not an MDI child) */
104  if ((Style & WS_CHILD) && !(ExStyle & WS_EX_MDICHILD))
105  {
110  }
111 }
112 
113 /***********************************************************************
114  * NC_GetSysPopupPos
115  */
116 void FASTCALL
118 {
119  RECT WindowRect;
120 
121  if ((Wnd->style & WS_MINIMIZE) != 0)
122  {
123  IntGetWindowRect(Wnd, Rect);
124  }
125  else
126  {
127  NC_GetInsideRect(Wnd, Rect);
128  IntGetWindowRect(Wnd, &WindowRect);
129  RECTL_vOffsetRect(Rect, WindowRect.left, WindowRect.top);
130  if (Wnd->style & WS_CHILD)
131  {
133  }
134  Rect->right = Rect->left + UserGetSystemMetrics(SM_CYCAPTION) - 1;
135  Rect->bottom = Rect->top + UserGetSystemMetrics(SM_CYCAPTION) - 1;
136  }
137 }
138 
141 {
142  LONG hittest = 0;
143  POINT pt;
144  MSG msg;
145  RECT rectWindow;
146  ULONG Style = Wnd->style;
148 
149  rectWindow = Wnd->rcWindow;
150 
151  if ((wParam & 0xfff0) == SC_MOVE)
152  {
153  /* Move pointer at the center of the caption */
154  RECT rect = rectWindow;
155  /* Note: to be exactly centered we should take the different types
156  * of border into account, but it shouldn't make more than a few pixels
157  * of difference so let's not bother with that */
158  if (Style & WS_SYSMENU)
159  rect.left += UserGetSystemMetrics(SM_CXSIZE) + 1;
160  if (Style & WS_MINIMIZEBOX)
161  rect.right -= UserGetSystemMetrics(SM_CXSIZE) + 1;
162  if (Style & WS_MAXIMIZEBOX)
163  rect.right -= UserGetSystemMetrics(SM_CXSIZE) + 1;
164  pt.x = (rect.right + rect.left) / 2;
165  pt.y = rect.top + UserGetSystemMetrics(SM_CYSIZE)/2;
166  hittest = HTCAPTION;
167  *capturePoint = pt;
168  }
169  else /* SC_SIZE */
170  {
171  pt.x = pt.y = 0;
172  while (!hittest)
173  {
174  if (!co_IntGetPeekMessage(&msg, 0, 0, 0, PM_REMOVE, TRUE)) return 0;
175  if (IntCallMsgFilter( &msg, MSGF_SIZE )) continue;
176 
177  switch(msg.message)
178  {
179  case WM_MOUSEMOVE:
181  pt.x = min( max( msg.pt.x, rectWindow.left ), rectWindow.right - 1 );
182  pt.y = min( max( msg.pt.y, rectWindow.top ), rectWindow.bottom - 1 );
183  hittest = GetNCHitEx(Wnd, pt);
184  if ((hittest < HTLEFT) || (hittest > HTBOTTOMRIGHT)) hittest = 0;
185  break;
186 
187  case WM_LBUTTONUP:
188  return 0;
189 
190  case WM_KEYDOWN:
191  switch (msg.wParam)
192  {
193  case VK_UP:
194  hittest = HTTOP;
195  pt.x = (rectWindow.left+rectWindow.right)/2;
196  pt.y = rectWindow.top + UserGetSystemMetrics(SM_CYFRAME) / 2;
197  break;
198  case VK_DOWN:
199  hittest = HTBOTTOM;
200  pt.x = (rectWindow.left+rectWindow.right)/2;
201  pt.y = rectWindow.bottom - UserGetSystemMetrics(SM_CYFRAME) / 2;
202  break;
203  case VK_LEFT:
204  hittest = HTLEFT;
205  pt.x = rectWindow.left + UserGetSystemMetrics(SM_CXFRAME) / 2;
206  pt.y = (rectWindow.top+rectWindow.bottom)/2;
207  break;
208  case VK_RIGHT:
209  hittest = HTRIGHT;
210  pt.x = rectWindow.right - UserGetSystemMetrics(SM_CXFRAME) / 2;
211  pt.y = (rectWindow.top+rectWindow.bottom)/2;
212  break;
213  case VK_RETURN:
214  case VK_ESCAPE:
215  return 0;
216  }
217  break;
218  default:
223  break;
224  }
225  }
226  *capturePoint = pt;
227  }
228  UserSetCursorPos(pt.x, pt.y, 0, 0, FALSE);
230  return hittest;
231 }
232 
233 //
234 // System Command Size and Move
235 //
236 // Perform SC_MOVE and SC_SIZE commands.
237 //
240 {
241  MSG msg;
242  RECT sizingRect, mouseRect, origRect, unmodRect;
243  HDC hdc;
244  LONG hittest = (LONG)(wParam & 0x0f);
245  PCURICON_OBJECT DragCursor = NULL, OldCursor = NULL;
246  POINT minTrack, maxTrack;
247  POINT capturePoint, pt;
249  BOOL thickframe;
250  BOOL iconic;
251  BOOL moved = FALSE;
252  BOOL DragFullWindows = FALSE;
253  PWND pWndParent = NULL;
254  WPARAM syscommand = (wParam & 0xfff0);
256  //PMONITOR mon = 0; Don't port sync from wine!!! This breaks explorer task bar sizing!!
257  // The task bar can grow in size and can not reduce due to the change
258  // in the work area.
259  DWORD ExStyleTB, StyleTB;
260  BOOL IsTaskBar;
261 
262  Style = pwnd->style;
263  ExStyle = pwnd->ExStyle;
264  iconic = (Style & WS_MINIMIZE) != 0;
265 
266  if (((Style & WS_MAXIMIZE) && syscommand != SC_MOVE) || !IntIsWindowVisible(pwnd)) return;
267 
268  thickframe = UserHasThickFrameStyle(Style, ExStyle) && !iconic;
269 
270  //
271  // Show window contents while dragging the window, get flag from registry data.
272  //
273  UserSystemParametersInfo(SPI_GETDRAGFULLWINDOWS, 0, &DragFullWindows, 0);
274 
275  pt.x = pti->ptLast.x;
276  pt.y = pti->ptLast.y;
277  capturePoint = pt;
278  UserClipCursor( NULL );
279 
280  TRACE("pwnd %p command %04lx, hittest %d, pos %d,%d\n",
281  pwnd, syscommand, hittest, pt.x, pt.y);
282 
283  if (syscommand == SC_MOVE)
284  {
285  if (!hittest) hittest = DefWndStartSizeMove(pwnd, wParam, &capturePoint);
286  if (!hittest) return;
287  }
288  else /* SC_SIZE */
289  {
290  if (!thickframe) return;
291  if (hittest && (syscommand != SC_MOUSEMENU))
292  {
293  hittest += (HTLEFT - WMSZ_LEFT);
294  }
295  else
296  {
298  hittest = DefWndStartSizeMove(pwnd, wParam, &capturePoint);
299  if (!hittest)
300  {
302  return;
303  }
304  }
305  }
306 
307  /* Get min/max info */
308 
309  co_WinPosGetMinMaxInfo(pwnd, NULL, NULL, &minTrack, &maxTrack);
310  sizingRect = pwnd->rcWindow;
311  origRect = sizingRect;
312  if (Style & WS_CHILD)
313  {
314  pWndParent = IntGetParent(pwnd);
315  IntGetClientRect( pWndParent, &mouseRect );
316  IntMapWindowPoints( pWndParent, 0, (LPPOINT)&mouseRect, 2 );
317  IntMapWindowPoints( 0, pWndParent, (LPPOINT)&sizingRect, 2 );
318  unmodRect = sizingRect;
319  }
320  else
321  {
322  if (!(ExStyle & WS_EX_TOPMOST))
323  {
324  UserSystemParametersInfo(SPI_GETWORKAREA, 0, &mouseRect, 0);
325  }
326  else
327  {
329  }
330  unmodRect = sizingRect;
331  }
332 
333  if (ON_LEFT_BORDER(hittest))
334  {
335  mouseRect.left = max( mouseRect.left, sizingRect.right-maxTrack.x+capturePoint.x-sizingRect.left );
336  mouseRect.right = min( mouseRect.right, sizingRect.right-minTrack.x+capturePoint.x-sizingRect.left );
337  }
338  else if (ON_RIGHT_BORDER(hittest))
339  {
340  mouseRect.left = max( mouseRect.left, sizingRect.left+minTrack.x+capturePoint.x-sizingRect.right );
341  mouseRect.right = min( mouseRect.right, sizingRect.left+maxTrack.x+capturePoint.x-sizingRect.right );
342  }
343  if (ON_TOP_BORDER(hittest))
344  {
345  mouseRect.top = max( mouseRect.top, sizingRect.bottom-maxTrack.y+capturePoint.y-sizingRect.top );
346  mouseRect.bottom = min( mouseRect.bottom,sizingRect.bottom-minTrack.y+capturePoint.y-sizingRect.top);
347  }
348  else if (ON_BOTTOM_BORDER(hittest))
349  {
350  mouseRect.top = max( mouseRect.top, sizingRect.top+minTrack.y+capturePoint.y-sizingRect.bottom );
351  mouseRect.bottom = min( mouseRect.bottom, sizingRect.top+maxTrack.y+capturePoint.y-sizingRect.bottom );
352  }
353 
354  hdc = UserGetDCEx( pWndParent, 0, DCX_CACHE );
355  if (iconic)
356  {
357  DragCursor = pwnd->pcls->spicn;
358  if (DragCursor)
359  {
360  UserReferenceObject(DragCursor);
361  }
362  else
363  {
364  HCURSOR CursorHandle = (HCURSOR)co_IntSendMessage( UserHMGetHandle(pwnd), WM_QUERYDRAGICON, 0, 0 );
365  if (CursorHandle)
366  {
367  DragCursor = UserGetCurIconObject(CursorHandle);
368  }
369  else
370  {
371  iconic = FALSE;
372  }
373  }
374  }
375 
376  /* repaint the window before moving it around */
378 
379  IntNotifyWinEvent( EVENT_SYSTEM_MOVESIZESTART, pwnd, OBJID_WINDOW, CHILDID_SELF, 0);
380 
382 
384 
386 
387  pwnd->head.pti->TIF_flags |= TIF_MOVESIZETRACKING;
388 
389  for(;;)
390  {
391  int dx = 0, dy = 0;
392 
393  if (!co_IntGetPeekMessage(&msg, 0, 0, 0, PM_REMOVE, TRUE)) break;
394  if (IntCallMsgFilter( &msg, MSGF_SIZE )) continue;
395 
396  /* Exit on button-up */
397  if (msg.message == WM_LBUTTONUP)
398  {
399  /* Test for typical TaskBar ExStyle Values */
400  ExStyleTB = (ExStyle & WS_EX_TOOLWINDOW);
401  TRACE("ExStyle is '%x'.\n", ExStyleTB);
402 
403  /* Test for typical TaskBar Style Values */
404  StyleTB = (Style & (WS_POPUP | WS_VISIBLE |
406  TRACE("Style is '%x'.\n", StyleTB);
407 
408  /* Test for masked typical TaskBar Style and ExStyles to detect TaskBar */
409  IsTaskBar = (StyleTB == (WS_POPUP | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN))
410  && (ExStyleTB == WS_EX_TOOLWINDOW);
411  TRACE("This %s the TaskBar.\n", IsTaskBar ? "is" : "is not");
412 
413  // check for snapping if was moved by caption
414  if (hittest == HTCAPTION && thickframe && (ExStyle & WS_EX_MDICHILD) == 0)
415  {
416  RECT snapRect;
417  BOOL doSideSnap = FALSE;
418  UserSystemParametersInfo(SPI_GETWORKAREA, 0, &snapRect, 0);
419 
420  /* if this is the taskbar, then we want to just exit */
421  if (IsTaskBar)
422  {
423  break;
424  }
425  // snap to left
426  if (pt.x <= snapRect.left)
427  {
428  snapRect.right = (snapRect.right - snapRect.left) / 2 + snapRect.left;
429  doSideSnap = TRUE;
430  }
431  // snap to right
432  if (pt.x >= snapRect.right-1)
433  {
434  snapRect.left = (snapRect.right - snapRect.left) / 2 + snapRect.left;
435  doSideSnap = TRUE;
436  }
437 
438  if (doSideSnap)
439  {
441  NULL,
442  snapRect.left,
443  snapRect.top,
444  snapRect.right - snapRect.left,
445  snapRect.bottom - snapRect.top,
447  pwnd->InternalPos.NormalRect = origRect;
448  }
449  else
450  {
451  // maximize if on dragged to top
452  if (pt.y <= snapRect.top)
453  {
455  pwnd->InternalPos.NormalRect = origRect;
456  }
457  }
458  }
459  break;
460  }
461 
462  /* Exit on Return or Esc */
463  if (msg.message == WM_KEYDOWN &&
464  (msg.wParam == VK_RETURN || msg.wParam == VK_ESCAPE))
465  {
466  break;
467  }
468 
469  if ((msg.message != WM_KEYDOWN) && (msg.message != WM_MOUSEMOVE))
470  {
471  IntTranslateKbdMessage( &msg , 0 );
473  continue; /* We are not interested in other messages */
474  }
475 
476  pt = msg.pt;
477 
478  if (msg.message == WM_KEYDOWN) switch(msg.wParam)
479  {
480  case VK_UP: pt.y -= 8; break;
481  case VK_DOWN: pt.y += 8; break;
482  case VK_LEFT: pt.x -= 8; break;
483  case VK_RIGHT: pt.x += 8; break;
484  }
485 
486  pt.x = max( pt.x, mouseRect.left );
487  pt.x = min( pt.x, mouseRect.right - 1 );
488  pt.y = max( pt.y, mouseRect.top );
489  pt.y = min( pt.y, mouseRect.bottom - 1 );
490 
491  dx = pt.x - capturePoint.x;
492  dy = pt.y - capturePoint.y;
493 
494  if (dx || dy)
495  {
496  if ( !moved )
497  {
498  moved = TRUE;
499  if ( iconic ) /* ok, no system popup tracking */
500  {
501  OldCursor = UserSetCursor(DragCursor, FALSE);
502  UserShowCursor( TRUE );
503  }
504  else if(!DragFullWindows)
505  UserDrawMovingFrame( hdc, &sizingRect, thickframe );
506  }
507 
508  if (msg.message == WM_KEYDOWN) UserSetCursorPos(pt.x, pt.y, 0, 0, FALSE);
509  else
510  {
511  RECT newRect = unmodRect;
512 
513  if (!iconic && !DragFullWindows) UserDrawMovingFrame( hdc, &sizingRect, thickframe );
514  if (hittest == HTCAPTION)
515  {
516  /* Restore window size if it is snapped */
517  if (!RECTL_bIsEmptyRect(&pwnd->InternalPos.NormalRect) &&
518  !IntEqualRect(&pwnd->InternalPos.NormalRect, &pwnd->rcWindow))
519  {
520  UserSetCursorPos(max(0, pwnd->InternalPos.NormalRect.left) + pt.x, pwnd->InternalPos.NormalRect.top + pt.y, 0, 0, FALSE);
521 
522  /* Save normal size - it required when window unsnapped from one side and snapped to another holding mouse down */
523  origRect = pwnd->InternalPos.NormalRect;
524 
525  /* Restore from maximized state */
526  if (Style & WS_MAXIMIZE)
527  {
529  }
530  /* Restore snapped to left/right place */
531  else
532  {
534  NULL,
535  pwnd->InternalPos.NormalRect.left,
536  pwnd->InternalPos.NormalRect.top,
537  pwnd->InternalPos.NormalRect.right - pwnd->InternalPos.NormalRect.left,
538  pwnd->InternalPos.NormalRect.bottom - pwnd->InternalPos.NormalRect.top,
539  0);
540  }
541  RECTL_vSetEmptyRect(&pwnd->InternalPos.NormalRect);
542  continue;
543  }
544 
545  /* regular window moving */
546  RECTL_vOffsetRect(&newRect, dx, dy);
547  }
548  if (ON_LEFT_BORDER(hittest)) newRect.left += dx;
549  else if (ON_RIGHT_BORDER(hittest)) newRect.right += dx;
550  if (ON_TOP_BORDER(hittest)) newRect.top += dy;
551  else if (ON_BOTTOM_BORDER(hittest)) newRect.bottom += dy;
552  capturePoint = pt;
553 
554  //
555  // Save the new position to the unmodified rectangle. This allows explorer task bar
556  // sizing. Explorer will forces back the position unless a certain amount of sizing
557  // has occurred.
558  //
559  unmodRect = newRect;
560 
561  /* determine the hit location */
562  if (syscommand == SC_SIZE)
563  {
564  WPARAM wpSizingHit = 0;
565 
566  if (hittest >= HTLEFT && hittest <= HTBOTTOMRIGHT)
567  wpSizingHit = WMSZ_LEFT + (hittest - HTLEFT);
568  co_IntSendMessage( UserHMGetHandle(pwnd), WM_SIZING, wpSizingHit, (LPARAM)&newRect );
569  }
570  else
571  co_IntSendMessage( UserHMGetHandle(pwnd), WM_MOVING, 0, (LPARAM)&newRect );
572 
573  if (!iconic)
574  {
575  if (!DragFullWindows)
576  UserDrawMovingFrame( hdc, &newRect, thickframe );
577  else
578  { // Moving the whole window now!
579  HRGN hrgnNew;
580  HRGN hrgnOrig = GreCreateRectRgnIndirect(&pwnd->rcWindow);
581 
582  if (pwnd->hrgnClip != NULL)
583  NtGdiCombineRgn(hrgnOrig, hrgnOrig, pwnd->hrgnClip, RGN_AND);
584 
586  //IntMapWindowPoints( 0, pWndParent, (POINT *)&rect, 2 );
588  NULL,
589  newRect.left,
590  newRect.top,
591  newRect.right - newRect.left,
592  newRect.bottom - newRect.top,
593  SWP_NOACTIVATE | ((hittest == HTCAPTION) ? SWP_NOSIZE : 0));
594 
595  hrgnNew = GreCreateRectRgnIndirect(&pwnd->rcWindow);
596  if (pwnd->hrgnClip != NULL)
597  NtGdiCombineRgn(hrgnNew, hrgnNew, pwnd->hrgnClip, RGN_AND);
598 
599  if (hrgnNew)
600  {
601  if (hrgnOrig)
602  NtGdiCombineRgn(hrgnOrig, hrgnOrig, hrgnNew, RGN_DIFF);
603  }
604  else
605  {
606  if (hrgnOrig)
607  {
608  GreDeleteObject(hrgnOrig);
609  hrgnOrig = 0;
610  }
611  }
612 
613  // Update all the windows after the move or size, including this window.
614  UpdateThreadWindows(UserGetDesktopWindow()->spwndChild, pti, hrgnOrig);
615 
616  if (hrgnOrig) GreDeleteObject(hrgnOrig);
617  if (hrgnNew) GreDeleteObject(hrgnNew);
618  }
619  }
620  sizingRect = newRect;
621  }
622  }
623  }
624 
625  pwnd->head.pti->TIF_flags &= ~TIF_MOVESIZETRACKING;
626 
628 
629  if ( iconic )
630  {
631  if ( moved ) /* restore cursors, show icon title later on */
632  {
634  OldCursor = UserSetCursor(OldCursor, FALSE);
635  }
636 
637  /* It could be that the cursor was already changed while we were proceeding,
638  * so we must unreference whatever cursor was current at the time we restored the old one.
639  * Maybe it is DragCursor, but maybe it is another one and DragCursor got already freed.
640  */
641  if (OldCursor) UserDereferenceObject(OldCursor);
642  }
643  else if ( moved && !DragFullWindows )
644  UserDrawMovingFrame( hdc, &sizingRect, thickframe );
645 
647 
649  //if (pWndParent) IntMapWindowPoints( 0, pWndParent, (POINT *)&sizingRect, 2 );
650 
652  {
653  ERR("DoSizeMove : WH_CBT Call Hook return!\n");
654  moved = FALSE;
655  }
656 
657  IntNotifyWinEvent( EVENT_SYSTEM_MOVESIZEEND, pwnd, OBJID_WINDOW, CHILDID_SELF, 0);
658 
660 
665  /* window moved or resized */
666  if (moved)
667  {
668  /* if the moving/resizing isn't canceled call SetWindowPos
669  * with the new position or the new size of the window
670  */
671  if (!((msg.message == WM_KEYDOWN) && (msg.wParam == VK_ESCAPE)) )
672  {
673  /* NOTE: SWP_NOACTIVATE prevents document window activation in Word 6 */
674  if (!DragFullWindows || iconic )
675  {
676  co_WinPosSetWindowPos( pwnd,
677  0,
678  sizingRect.left,
679  sizingRect.top,
680  sizingRect.right - sizingRect.left,
681  sizingRect.bottom - sizingRect.top,
682  ( hittest == HTCAPTION ) ? SWP_NOSIZE : 0 );
683  }
684  }
685  else
686  { /* restore previous size/position */
687  if ( DragFullWindows )
688  {
689  co_WinPosSetWindowPos( pwnd,
690  0,
691  origRect.left,
692  origRect.top,
693  origRect.right - origRect.left,
694  origRect.bottom - origRect.top,
695  ( hittest == HTCAPTION ) ? SWP_NOSIZE : 0 );
696  }
697  }
698  }
699 
700  if ( IntIsWindow(UserHMGetHandle(pwnd)) )
701  {
702  if ( iconic )
703  {
704  /* Single click brings up the system menu when iconized */
705  if ( !moved )
706  {
707  if( Style & WS_SYSMENU )
709  }
710  }
711  }
712 }
713 
715 {
716  PCURICON_OBJECT pIcon = NULL;
717  HICON hIcon;
718 
720  if (!hIcon) hIcon = UserGetProp(pWnd, gpsi->atomIconProp, TRUE);
721 
722  if (!hIcon && pWnd->pcls->spicnSm)
723  return pWnd->pcls->spicnSm;
724  if (!hIcon && pWnd->pcls->spicn)
725  return pWnd->pcls->spicn;
726 
727  // WARNING: Wine code has this test completely wrong. The following is how
728  // Windows behaves for windows having the WS_EX_DLGMODALFRAME style set:
729  // it does not use the default icon! And it does not check for DS_MODALFRAME.
730  if (!hIcon && !(pWnd->ExStyle & WS_EX_DLGMODALFRAME))
731  {
732  hIcon = gpsi->hIconSmWindows; // Both are IDI_WINLOGO Small
733  if (!hIcon) hIcon = gpsi->hIconWindows; // Reg size.
734  }
735  if (hIcon)
736  {
738  hIcon,
739  TYPE_CURSOR);
740  }
741  return pIcon;
742 }
743 
744 BOOL
746 {
747  PCURICON_OBJECT WindowIcon;
748  BOOL Ret = FALSE;
749 
750  if ((WindowIcon = NC_IconForWindow(pWnd)))
751  {
752  UserReferenceObject(WindowIcon);
753 
754  Ret = UserDrawIconEx(hDC,
755  Rect->left + 2,
756  Rect->top + 2,
757  WindowIcon,
760  0, NULL, DI_NORMAL);
761 
762  UserDereferenceObject(WindowIcon);
763  }
764  return Ret;
765 }
766 
767 BOOL
769 {
770  SCROLLBARINFO sbi;
771  sbi.cbSize = sizeof(SCROLLBARINFO);
772 
773  if(!co_IntGetScrollBarInfo(pWnd, hBar, &sbi))
774  return FALSE;
775 
776  return !(sbi.rgstate[0] & STATE_SYSTEM_OFFSCREEN);
777 }
778 
779 /*
780  * FIXME:
781  * - Cache bitmaps, then just bitblt instead of calling DFC() (and
782  * wasting precious CPU cycles) every time
783  * - Center the buttons vertically in the rect
784  */
785 VOID
787 {
788  RECT TempRect;
789 
790  if (!(Style & WS_SYSMENU))
791  {
792  return;
793  }
794 
795  TempRect = *Rect;
796 
797  switch (Type)
798  {
799  case DFCS_CAPTIONMIN:
800  {
802  return; /* ToolWindows don't have min/max buttons */
803 
804  if (Style & WS_SYSMENU)
805  TempRect.right -= UserGetSystemMetrics(SM_CXSIZE) + 1;
806 
808  TempRect.right -= UserGetSystemMetrics(SM_CXSIZE) - 2;
809 
810  TempRect.left = TempRect.right - UserGetSystemMetrics(SM_CXSIZE) + 1;
811  TempRect.bottom = TempRect.top + UserGetSystemMetrics(SM_CYSIZE) - 2;
812  TempRect.top += 2;
813  TempRect.right -= 1;
814 
815  DrawFrameControl(hDC, &TempRect, DFC_CAPTION,
817  (bDown ? DFCS_PUSHED : 0) |
818  ((Style & WS_MINIMIZEBOX) ? 0 : DFCS_INACTIVE));
819  break;
820  }
821  case DFCS_CAPTIONMAX:
822  {
824  return; /* ToolWindows don't have min/max buttons */
825 
826  if (Style & WS_SYSMENU)
827  TempRect.right -= UserGetSystemMetrics(SM_CXSIZE) + 1;
828 
829  TempRect.left = TempRect.right - UserGetSystemMetrics(SM_CXSIZE) + 1;
830  TempRect.bottom = TempRect.top + UserGetSystemMetrics(SM_CYSIZE) - 2;
831  TempRect.top += 2;
832  TempRect.right -= 1;
833 
834  DrawFrameControl(hDC, &TempRect, DFC_CAPTION,
836  (bDown ? DFCS_PUSHED : 0) |
837  ((Style & WS_MAXIMIZEBOX) ? 0 : DFCS_INACTIVE));
838  break;
839  }
840  case DFCS_CAPTIONCLOSE:
841  {
842  PMENU pSysMenu = IntGetSystemMenu(pWnd, FALSE);
843  UINT MenuState = IntGetMenuState(pSysMenu ? UserHMGetHandle(pSysMenu) : NULL, SC_CLOSE, MF_BYCOMMAND); /* in case of error MenuState==0xFFFFFFFF */
844 
845  /* A tool window has a smaller Close button */
847  {
848  TempRect.left = TempRect.right - UserGetSystemMetrics(SM_CXSMSIZE);
849  TempRect.bottom = TempRect.top + UserGetSystemMetrics(SM_CYSMSIZE) - 2;
850  }
851  else
852  {
853  TempRect.left = TempRect.right - UserGetSystemMetrics(SM_CXSIZE);
854  TempRect.bottom = TempRect.top + UserGetSystemMetrics(SM_CYSIZE) - 2;
855  }
856  TempRect.top += 2;
857  TempRect.right -= 2;
858 
859  DrawFrameControl(hDC, &TempRect, DFC_CAPTION,
860  (DFCS_CAPTIONCLOSE | (bDown ? DFCS_PUSHED : 0) |
861  ((!(MenuState & (MF_GRAYED|MF_DISABLED)) && !(pWnd->pcls->style & CS_NOCLOSE)) ? 0 : DFCS_INACTIVE)));
862  break;
863  }
864  }
865 }
866 
867 VOID
869 {
870  RECT WindowRect;
871  SIZE WindowBorder;
872 
873  IntGetWindowRect(pWnd, &WindowRect);
874 
875  WindowRect.right -= WindowRect.left;
876  WindowRect.bottom -= WindowRect.top;
877  WindowRect.left = WindowRect.top = 0;
878 
879  UserGetWindowBorders(pWnd->style, pWnd->ExStyle, &WindowBorder, FALSE);
880 
881  RECTL_vInflateRect(&WindowRect, -WindowBorder.cx, -WindowBorder.cy);
882 
883  UserDrawCaptionButton(pWnd, &WindowRect, pWnd->style, pWnd->ExStyle, hDC, bDown, Type);
884 }
885 
886 VOID
888 {
889  /* Firstly the "thick" frame */
890  if ((Style & WS_THICKFRAME) && !(Style & WS_MINIMIZE))
891  {
892  LONG Width =
895 
896  LONG Height =
899 
901 
902  /* Draw frame */
903  NtGdiPatBlt(hDC, CurrentRect->left, CurrentRect->top, CurrentRect->right - CurrentRect->left, Height, PATCOPY);
904  NtGdiPatBlt(hDC, CurrentRect->left, CurrentRect->top, Width, CurrentRect->bottom - CurrentRect->top, PATCOPY);
905  NtGdiPatBlt(hDC, CurrentRect->left, CurrentRect->bottom - 1, CurrentRect->right - CurrentRect->left, -Height, PATCOPY);
906  NtGdiPatBlt(hDC, CurrentRect->right - 1, CurrentRect->top, -Width, CurrentRect->bottom - CurrentRect->top, PATCOPY);
907 
908  RECTL_vInflateRect(CurrentRect, -Width, -Height);
909  }
910 
911  /* Now the other bit of the frame */
913  {
916 
922 
923  /* Draw frame */
924  NtGdiPatBlt(hDC, CurrentRect->left, CurrentRect->top, CurrentRect->right - CurrentRect->left, Height, PATCOPY);
925  NtGdiPatBlt(hDC, CurrentRect->left, CurrentRect->top, Width, CurrentRect->bottom - CurrentRect->top, PATCOPY);
926  NtGdiPatBlt(hDC, CurrentRect->left, CurrentRect->bottom - 1, CurrentRect->right - CurrentRect->left, -Height, PATCOPY);
927  NtGdiPatBlt(hDC, CurrentRect->right - 1, CurrentRect->top, -Width, CurrentRect->bottom - CurrentRect->top, PATCOPY);
928 
929  RECTL_vInflateRect(CurrentRect, -Width, -Height);
930  }
931 }
932 
934  PWND pWnd,
935  HDC hDC,
936  INT Flags)
937 {
939  RECT WindowRect, CurrentRect, TempRect;
940  HPEN PreviousPen;
941  BOOL Gradient = FALSE;
942  PCURICON_OBJECT pIcon = NULL;
943 
944  if (!(Flags & DC_NOVISIBLE) && !IntIsWindowVisible(pWnd)) return;
945 
946  TRACE("UserDrawCaptionBar: pWnd %p, hDc %p, Flags 0x%x.\n", pWnd, hDC, Flags);
947 
948  Style = pWnd->style;
949  ExStyle = pWnd->ExStyle;
950 
951  IntGetWindowRect(pWnd, &WindowRect);
952 
953  CurrentRect.top = CurrentRect.left = 0;
954  CurrentRect.right = WindowRect.right - WindowRect.left;
955  CurrentRect.bottom = WindowRect.bottom - WindowRect.top;
956 
957  /* Draw outer edge */
959  {
960  DrawEdge(hDC, &CurrentRect, EDGE_RAISED, BF_RECT | BF_ADJUST);
961  }
962  else if (ExStyle & WS_EX_STATICEDGE)
963  {
964 #if 0
965  DrawEdge(hDC, &CurrentRect, BDR_SUNKENINNER, BF_RECT | BF_ADJUST | BF_FLAT);
966 #else
968  NtGdiPatBlt(hDC, CurrentRect.left, CurrentRect.top, CurrentRect.right - CurrentRect.left, 1, PATCOPY);
969  NtGdiPatBlt(hDC, CurrentRect.left, CurrentRect.top, 1, CurrentRect.bottom - CurrentRect.top, PATCOPY);
970 
972  NtGdiPatBlt(hDC, CurrentRect.left, CurrentRect.bottom - 1, CurrentRect.right - CurrentRect.left, 1, PATCOPY);
973  NtGdiPatBlt(hDC, CurrentRect.right - 1, CurrentRect.top, 1, CurrentRect.bottom - CurrentRect.top, PATCOPY);
974 
975  RECTL_vInflateRect(&CurrentRect, -1, -1);
976 #endif
977  }
978 
979  if (Flags & DC_FRAME) NC_DrawFrame(hDC, &CurrentRect, (Flags & DC_ACTIVE), Style, ExStyle);
980 
981  /* Draw caption */
982  if ((Style & WS_CAPTION) == WS_CAPTION)
983  {
984  TempRect = CurrentRect;
985 
986  Flags |= DC_TEXT|DC_BUTTONS; // Icon will be checked if not already set.
987 
988  if (UserSystemParametersInfo(SPI_GETGRADIENTCAPTIONS, 0, &Gradient, 0) && Gradient)
989  {
990  Flags |= DC_GRADIENT;
991  }
992 
994  {
995  Flags |= DC_SMALLCAP;
996  TempRect.bottom = TempRect.top + UserGetSystemMetrics(SM_CYSMCAPTION) - 1;
997  CurrentRect.top += UserGetSystemMetrics(SM_CYSMCAPTION);
998  }
999  else
1000  {
1001  TempRect.bottom = TempRect.top + UserGetSystemMetrics(SM_CYCAPTION) - 1;
1002  CurrentRect.top += UserGetSystemMetrics(SM_CYCAPTION);
1003  }
1004 
1005  if (!(Flags & DC_ICON) &&
1006  !(Flags & DC_SMALLCAP) &&
1007  (Style & WS_SYSMENU) &&
1008  !(ExStyle & WS_EX_TOOLWINDOW) )
1009  {
1010  pIcon = NC_IconForWindow(pWnd); // Force redraw of caption with icon if DC_ICON not flaged....
1011  }
1012  UserDrawCaption(pWnd, hDC, &TempRect, NULL, pIcon ? UserHMGetHandle(pIcon) : NULL, NULL, Flags);
1013 
1014  /* Draw buttons */
1015  if (Style & WS_SYSMENU)
1016  {
1019  {
1022  }
1023  }
1024 
1025  if (!(Style & WS_MINIMIZE))
1026  {
1027  /* Line under caption */
1028  PreviousPen = NtGdiSelectPen(hDC, NtGdiGetStockObject(DC_PEN));
1029 
1032 
1033  GreMoveTo(hDC, TempRect.left, TempRect.bottom, NULL);
1034 
1035  NtGdiLineTo(hDC, TempRect.right, TempRect.bottom);
1036 
1037  NtGdiSelectPen(hDC, PreviousPen);
1038  }
1039  }
1040 
1041  if (!(Style & WS_MINIMIZE))
1042  {
1043  /* Draw menu bar */
1044  if (pWnd->state & WNDS_HASMENU && pWnd->IDMenu) // Should be pWnd->spmenu
1045  {
1046  PMENU menu;
1047  if ((menu = UserGetMenuObject(UlongToHandle(pWnd->IDMenu)))) // FIXME! Use pWnd->spmenu,
1048  {
1049  TempRect = CurrentRect;
1050  TempRect.bottom = TempRect.top + menu->cyMenu; // Should be pWnd->spmenu->cyMenu;
1051  CurrentRect.top += MENU_DrawMenuBar(hDC, &TempRect, pWnd, FALSE);
1052  }
1053  }
1054 
1055  if (ExStyle & WS_EX_CLIENTEDGE)
1056  {
1057  DrawEdge(hDC, &CurrentRect, EDGE_SUNKEN, BF_RECT | BF_ADJUST);
1058  }
1059  }
1060 }
1061 
1062 // Note from Wine:
1063 /* MSDN docs are pretty idiotic here, they say app CAN use clipRgn in
1064  the call to GetDCEx implying that it is allowed not to use it either.
1065  However, the suggested GetDCEx( , DCX_WINDOW | DCX_INTERSECTRGN)
1066  will cause clipRgn to be deleted after ReleaseDC().
1067  Now, how is the "system" supposed to tell what happened?
1068  */
1069 /*
1070  * FIXME:
1071  * - Drawing of WS_BORDER after scrollbars
1072  * - Correct drawing of size-box
1073  */
1074 LRESULT
1076 {
1077  DWORD Style, ExStyle;
1078  PWND Parent;
1079  RECT WindowRect, CurrentRect, TempRect;
1080  BOOL Active = FALSE;
1081 
1082  if (!IntIsWindowVisible(pWnd) ||
1083  (pWnd->state & WNDS_NONCPAINT && !(pWnd->state & WNDS_FORCEMENUDRAW)) ||
1084  IntEqualRect(&pWnd->rcWindow, &pWnd->rcClient) )
1085  return 0;
1086 
1087  Style = pWnd->style;
1088 
1089  TRACE("DefWndNCPaint: pWnd %p, hDc %p, Active %s.\n", pWnd, hDC, Flags & DC_ACTIVE ? "TRUE" : "FALSE");
1090 
1091  Parent = IntGetParent(pWnd);
1092  ExStyle = pWnd->ExStyle;
1093 
1094  if (Flags == -1) // NC paint mode.
1095  {
1096  if (ExStyle & WS_EX_MDICHILD)
1097  {
1099 
1100  if (Active)
1102  }
1103  else
1104  {
1105  Active = (gpqForeground == pWnd->head.pti->MessageQueue);
1106  }
1107  Flags = DC_NC; // Redraw everything!
1108  }
1109  else
1110  Flags |= DC_NC;
1111 
1112 
1113  IntGetWindowRect(pWnd, &WindowRect);
1114 
1115  CurrentRect.top = CurrentRect.left = 0;
1116  CurrentRect.right = WindowRect.right - WindowRect.left;
1117  CurrentRect.bottom = WindowRect.bottom - WindowRect.top;
1118 
1119  /* Draw outer edge */
1120  if (UserHasWindowEdge(pWnd->style, pWnd->ExStyle))
1121  {
1122  DrawEdge(hDC, &CurrentRect, EDGE_RAISED, BF_RECT | BF_ADJUST);
1123  }
1124  else if (pWnd->ExStyle & WS_EX_STATICEDGE)
1125  {
1126 #if 0
1127  DrawEdge(hDC, &CurrentRect, BDR_SUNKENINNER, BF_RECT | BF_ADJUST | BF_FLAT);
1128 #else
1130  NtGdiPatBlt(hDC, CurrentRect.left, CurrentRect.top, CurrentRect.right - CurrentRect.left, 1, PATCOPY);
1131  NtGdiPatBlt(hDC, CurrentRect.left, CurrentRect.top, 1, CurrentRect.bottom - CurrentRect.top, PATCOPY);
1132 
1134  NtGdiPatBlt(hDC, CurrentRect.left, CurrentRect.bottom - 1, CurrentRect.right - CurrentRect.left, 1, PATCOPY);
1135  NtGdiPatBlt(hDC, CurrentRect.right - 1, CurrentRect.top, 1, CurrentRect.bottom - CurrentRect.top, PATCOPY);
1136 
1137  RECTL_vInflateRect(&CurrentRect, -1, -1);
1138 #endif
1139  }
1140 
1141  if (Flags & DC_FRAME) NC_DrawFrame(hDC, &CurrentRect, Active ? Active : (Flags & DC_ACTIVE), Style, ExStyle);
1142 
1143  /* Draw caption */
1144  if ((Style & WS_CAPTION) == WS_CAPTION)
1145  {
1146  HPEN PreviousPen;
1147  BOOL Gradient = FALSE;
1148 
1149  if (Flags & DC_REDRAWHUNGWND)
1150  {
1151  Flags &= ~DC_REDRAWHUNGWND;
1152  Flags |= DC_NOSENDMSG;
1153  }
1154 
1155  if (UserSystemParametersInfo(SPI_GETGRADIENTCAPTIONS, 0, &Gradient, 0) && Gradient)
1156  {
1157  Flags |= DC_GRADIENT;
1158  }
1159 
1160  if (Active)
1161  {
1162  if (pWnd->state & WNDS_ACTIVEFRAME)
1163  Flags |= DC_ACTIVE;
1164  else
1165  {
1166  ERR("Wnd is active and not set active!\n");
1167  }
1168  }
1169 
1170  TempRect = CurrentRect;
1171 
1172  if (ExStyle & WS_EX_TOOLWINDOW)
1173  {
1174  Flags |= DC_SMALLCAP;
1175  TempRect.bottom = TempRect.top + UserGetSystemMetrics(SM_CYSMCAPTION) - 1;
1176  CurrentRect.top += UserGetSystemMetrics(SM_CYSMCAPTION);
1177  }
1178  else
1179  {
1180  TempRect.bottom = TempRect.top + UserGetSystemMetrics(SM_CYCAPTION) - 1;
1181  CurrentRect.top += UserGetSystemMetrics(SM_CYCAPTION);
1182  }
1183 
1184  UserDrawCaption(pWnd, hDC, &TempRect, NULL, NULL, NULL, Flags);
1185 
1186  /* Draw buttons */
1187  if (Style & WS_SYSMENU)
1188  {
1191  {
1194  }
1195  }
1196  if (!(Style & WS_MINIMIZE))
1197  {
1198  /* Line under caption */
1199  PreviousPen = NtGdiSelectPen(hDC, NtGdiGetStockObject(DC_PEN));
1200 
1204 
1205  GreMoveTo(hDC, TempRect.left, TempRect.bottom, NULL);
1206 
1207  NtGdiLineTo(hDC, TempRect.right, TempRect.bottom);
1208 
1209  NtGdiSelectPen(hDC, PreviousPen);
1210  }
1211  }
1212 
1213  if (!(Style & WS_MINIMIZE))
1214  {
1215  /* Draw menu bar */
1216  if (pWnd->state & WNDS_HASMENU && pWnd->IDMenu) // Should be pWnd->spmenu
1217  {
1218  if (!(Flags & DC_NOSENDMSG))
1219  {
1220  PMENU menu;
1221  // Fix crash in test_menu_locked_by_window, should use pWnd->spmenu....
1222  if ((menu = UserGetMenuObject(UlongToHandle(pWnd->IDMenu)))) // FIXME! Use pWnd->spmenu,
1223  {
1224  TempRect = CurrentRect;
1225  TempRect.bottom = TempRect.top + menu->cyMenu; // Should be pWnd->spmenu->cyMenu;
1226  CurrentRect.top += MENU_DrawMenuBar(hDC, &TempRect, pWnd, FALSE);
1227  }
1228  }
1229  }
1230 
1231  if (ExStyle & WS_EX_CLIENTEDGE)
1232  {
1233  DrawEdge(hDC, &CurrentRect, EDGE_SUNKEN, BF_RECT | BF_ADJUST);
1234  }
1235 
1236  /* Draw the scrollbars */
1237  if ((Style & WS_VSCROLL) && (Style & WS_HSCROLL) &&
1239  {
1240  RECT ParentClientRect;
1241 
1242  TempRect = CurrentRect;
1243 
1245  TempRect.right = TempRect.left + UserGetSystemMetrics(SM_CXVSCROLL);
1246  else
1247  TempRect.left = TempRect.right - UserGetSystemMetrics(SM_CXVSCROLL);
1248 
1249  TempRect.top = TempRect.bottom - UserGetSystemMetrics(SM_CYHSCROLL);
1250 
1252 
1253  if (Parent)
1254  {
1255  IntGetClientRect(Parent, &ParentClientRect);
1256 
1257  if (HASSIZEGRIP(Style, ExStyle, Parent->style, WindowRect, ParentClientRect))
1258  {
1260  }
1261  }
1262 
1263  IntDrawScrollBar(pWnd, hDC, SB_VERT);
1264  IntDrawScrollBar(pWnd, hDC, SB_HORZ);
1265  }
1266  else
1267  {
1269  {
1270  IntDrawScrollBar(pWnd, hDC, SB_VERT);
1271  }
1272  else if (Style & WS_HSCROLL && IntIsScrollBarVisible(pWnd, OBJID_HSCROLL))
1273  {
1274  IntDrawScrollBar(pWnd, hDC, SB_HORZ);
1275  }
1276  }
1277  }
1278  return 0; // For WM_NCPAINT message, return 0.
1279 }
1280 
1281 /* Win: xxxCalcClientRect */
1283 {
1284  LRESULT Result = 0;
1285  SIZE WindowBorders;
1286  RECT OrigRect;
1287  LONG Style = Wnd->style;
1288  LONG exStyle = Wnd->ExStyle;
1289 
1290  if (Rect == NULL)
1291  {
1292  return Result;
1293  }
1294  OrigRect = *Rect;
1295 
1296  Wnd->state &= ~WNDS_HASCAPTION;
1297 
1298  if (wparam)
1299  {
1300  if (Wnd->pcls->style & CS_VREDRAW)
1301  {
1302  Result |= WVR_VREDRAW;
1303  }
1304  if (Wnd->pcls->style & CS_HREDRAW)
1305  {
1306  Result |= WVR_HREDRAW;
1307  }
1309  }
1310 
1311  if (!(Wnd->style & WS_MINIMIZE))
1312  {
1313  if (UserHasWindowEdge(Wnd->style, Wnd->ExStyle))
1314  {
1315  UserGetWindowBorders(Wnd->style, Wnd->ExStyle, &WindowBorders, FALSE);
1316  RECTL_vInflateRect(Rect, -WindowBorders.cx, -WindowBorders.cy);
1317  }
1318  else if ((Wnd->ExStyle & WS_EX_STATICEDGE) || (Wnd->style & WS_BORDER))
1319  {
1320  RECTL_vInflateRect(Rect, -1, -1);
1321  }
1322 
1323  if ((Wnd->style & WS_CAPTION) == WS_CAPTION)
1324  {
1325  Wnd->state |= WNDS_HASCAPTION;
1326 
1327  if (Wnd->ExStyle & WS_EX_TOOLWINDOW)
1329  else
1331  }
1332 
1333  if (HAS_MENU(Wnd, Style))
1334  {
1335  HDC hDC = UserGetDCEx(Wnd, 0, DCX_USESTYLE | DCX_WINDOW);
1336 
1337  Wnd->state |= WNDS_HASMENU;
1338 
1339  if (hDC)
1340  {
1341  RECT CliRect = *Rect;
1342  CliRect.bottom -= OrigRect.top;
1343  CliRect.right -= OrigRect.left;
1344  CliRect.left -= OrigRect.left;
1345  CliRect.top -= OrigRect.top;
1346  if (!Suspended) Rect->top += MENU_DrawMenuBar(hDC, &CliRect, Wnd, TRUE);
1347  UserReleaseDC(Wnd, hDC, FALSE);
1348  }
1349  }
1350 
1351  if (Wnd->ExStyle & WS_EX_CLIENTEDGE)
1352  {
1354  }
1355 
1356  if (Style & WS_VSCROLL)
1357  {
1358  if (Rect->right - Rect->left >= UserGetSystemMetrics(SM_CXVSCROLL))
1359  {
1361 
1362  /* rectangle is in screen coords when wparam is false */
1363  if (!wparam && (exStyle & WS_EX_LAYOUTRTL)) exStyle ^= WS_EX_LEFTSCROLLBAR;
1364 
1365  if((exStyle & WS_EX_LEFTSCROLLBAR) != 0)
1367  else
1369  }
1370  }
1371 
1372  if (Style & WS_HSCROLL)
1373  {
1374  if( Rect->bottom - Rect->top > UserGetSystemMetrics(SM_CYHSCROLL))
1375  {
1377 
1379  }
1380  }
1381 
1382  if (Rect->top > Rect->bottom)
1383  Rect->bottom = Rect->top;
1384 
1385  if (Rect->left > Rect->right)
1386  Rect->right = Rect->left;
1387  }
1388  else
1389  {
1390  Rect->right = Rect->left;
1391  Rect->bottom = Rect->top;
1392  }
1393 
1394  return Result;
1395 }
1396 
1397 static
1399 {
1400  INT Ret = 0;
1401 
1404  Ret = DC_CAPTION;
1405 
1406  if (!(Wnd->style & WS_MINIMIZED) && UserHasThickFrameStyle(Wnd->style, Wnd->ExStyle))
1407  {
1408  //if (IntGetSysColor(COLOR_ACTIVEBORDER) != IntGetSysColor(COLOR_INACTIVEBORDER)) // Why are these the same?
1409  {
1410  Ret = DC_FRAME;
1411  }
1412  }
1413  return Ret;
1414 }
1415 
1417 {
1418  INT Flags;
1419  /* Lotus Notes draws menu descriptions in the caption of its main
1420  * window. When it wants to restore original "system" view, it just
1421  * sends WM_NCACTIVATE message to itself. Any optimizations here in
1422  * attempt to minimize redrawings lead to a not restored caption.
1423  */
1424  if (wParam & DC_ACTIVE)
1425  {
1428  }
1429  else
1430  {
1431  Wnd->state &= ~WNDS_ACTIVEFRAME;
1432  wParam = DC_CAPTION;
1433  }
1434 
1435  if ((Wnd->state & WNDS_NONCPAINT) || !(Wnd->style & WS_VISIBLE))
1436  return TRUE;
1437 
1438  /* This isn't documented but is reproducible in at least XP SP2 and
1439  * Outlook 2007 depends on it
1440  */
1441  // MSDN:
1442  // If this parameter is set to -1, DefWindowProc does not repaint the
1443  // nonclient area to reflect the state change.
1444  if ( lParam != -1 &&
1445  ( Flags = NC_DoNCActive(Wnd)) != 0 )
1446  {
1447  HDC hDC;
1448  HRGN hRgnTemp = NULL, hRgn = (HRGN)lParam;
1449 
1450  if (GreIsHandleValid(hRgn))
1451  {
1452  hRgnTemp = NtGdiCreateRectRgn(0, 0, 0, 0);
1453  if (NtGdiCombineRgn(hRgnTemp, hRgn, 0, RGN_COPY) == ERROR)
1454  {
1455  GreDeleteObject(hRgnTemp);
1456  hRgnTemp = NULL;
1457  }
1458  }
1459 
1460  if ((hDC = UserGetDCEx(Wnd, hRgnTemp, DCX_WINDOW|DCX_USESTYLE)))
1461  {
1462  NC_DoNCPaint(Wnd, hDC, wParam | Flags); // Redraw MENUs.
1463  UserReleaseDC(Wnd, hDC, FALSE);
1464  }
1465  else
1466  GreDeleteObject(hRgnTemp);
1467  }
1468 
1469  return TRUE;
1470 }
1471 
1472 VOID
1474 {
1475  MSG Msg;
1476  HDC WindowDC;
1477  BOOL Pressed = TRUE, OldState;
1478  WPARAM SCMsg;
1479  PMENU SysMenu;
1480  ULONG ButtonType;
1481  DWORD Style;
1482  UINT MenuState;
1483 
1484  Style = pWnd->style;
1485  switch (wParam)
1486  {
1487  case HTCLOSE:
1488  SysMenu = IntGetSystemMenu(pWnd, FALSE);
1489  MenuState = IntGetMenuState(SysMenu ? UserHMGetHandle(SysMenu) : NULL, SC_CLOSE, MF_BYCOMMAND); /* in case of error MenuState==0xFFFFFFFF */
1490  if (!(Style & WS_SYSMENU) || (MenuState & (MF_GRAYED|MF_DISABLED)) || (pWnd->style & CS_NOCLOSE))
1491  return;
1492  ButtonType = DFCS_CAPTIONCLOSE;
1493  SCMsg = SC_CLOSE;
1494  break;
1495  case HTMINBUTTON:
1496  if (!(Style & WS_MINIMIZEBOX))
1497  return;
1498  ButtonType = DFCS_CAPTIONMIN;
1499  SCMsg = ((Style & WS_MINIMIZE) ? SC_RESTORE : SC_MINIMIZE);
1500  break;
1501  case HTMAXBUTTON:
1502  if (!(Style & WS_MAXIMIZEBOX))
1503  return;
1504  ButtonType = DFCS_CAPTIONMAX;
1505  SCMsg = ((Style & WS_MAXIMIZE) ? SC_RESTORE : SC_MAXIMIZE);
1506  break;
1507 
1508  default:
1509  ASSERT(FALSE);
1510  return;
1511  }
1512 
1513  /*
1514  * FIXME: Not sure where to do this, but we must flush the pending
1515  * window updates when someone clicks on the close button and at
1516  * the same time the window is overlapped with another one. This
1517  * looks like a good place for now...
1518  */
1520 
1521  WindowDC = UserGetWindowDC(pWnd);
1522  UserDrawCaptionButtonWnd(pWnd, WindowDC, TRUE, ButtonType);
1523 
1525 
1526  for (;;)
1527  {
1529  if (IntCallMsgFilter( &Msg, MSGF_MAX )) continue;
1530 
1531  if (Msg.message == WM_LBUTTONUP)
1532  break;
1533 
1534  if (Msg.message != WM_MOUSEMOVE)
1535  continue;
1536 
1537  OldState = Pressed;
1538  Pressed = (GetNCHitEx(pWnd, Msg.pt) == wParam);
1539  if (Pressed != OldState)
1540  UserDrawCaptionButtonWnd(pWnd, WindowDC, Pressed, ButtonType);
1541  }
1542 
1543  if (Pressed)
1544  UserDrawCaptionButtonWnd(pWnd, WindowDC, FALSE, ButtonType);
1546  UserReleaseDC(pWnd, WindowDC, FALSE);
1547  if (Pressed)
1548  co_IntSendMessage(UserHMGetHandle(pWnd), WM_SYSCOMMAND, SCMsg, SCMsg == SC_CLOSE ? lParam : MAKELONG(Msg.pt.x,Msg.pt.y));
1549 }
1550 
1551 
1552 LRESULT
1554 {
1555  switch (wParam)
1556  {
1557  case HTCAPTION:
1558  {
1559  PWND TopWnd = pWnd, parent;
1560  while(1)
1561  {
1562  if ((TopWnd->style & (WS_POPUP|WS_CHILD)) != WS_CHILD)
1563  break;
1564  parent = UserGetAncestor( TopWnd, GA_PARENT );
1565  if (!parent || UserIsDesktopWindow(parent)) break;
1566  TopWnd = parent;
1567  }
1568 
1569  if ( (pWnd && (pWnd->ExStyle & WS_EX_NOACTIVATE)) ||
1571  //NtUserCallHwndLock(hTopWnd, HWNDLOCK_ROUTINE_SETFOREGROUNDWINDOWMOUSE) ||
1572  UserGetActiveWindow() == UserHMGetHandle(TopWnd))
1573  {
1575  }
1576  break;
1577  }
1578  case HTSYSMENU:
1579  {
1580  LONG style = pWnd->style;
1581  if (style & WS_SYSMENU)
1582  {
1583  if(!(style & WS_MINIMIZE) )
1584  {
1585  RECT rect;
1586  HDC hDC = UserGetWindowDC(pWnd);
1587  NC_GetInsideRect(pWnd, &rect);
1588  UserDrawSysMenuButton(pWnd, hDC, &rect, TRUE);
1589  UserReleaseDC( pWnd, hDC, FALSE );
1590  }
1592  }
1593  break;
1594  }
1595  case HTMENU:
1596  {
1598  break;
1599  }
1600  case HTHSCROLL:
1601  {
1603  break;
1604  }
1605  case HTVSCROLL:
1606  {
1608  break;
1609  }
1610  case HTMINBUTTON:
1611  case HTMAXBUTTON:
1612  case HTCLOSE:
1613  {
1614  NC_DoButton(pWnd, wParam, lParam);
1615  break;
1616  }
1617  case HTLEFT:
1618  case HTRIGHT:
1619  case HTTOP:
1620  case HTBOTTOM:
1621  case HTTOPLEFT:
1622  case HTTOPRIGHT:
1623  case HTBOTTOMLEFT:
1624  case HTBOTTOMRIGHT:
1625  {
1626  /* Old comment:
1627  * "make sure hittest fits into 0xf and doesn't overlap with HTSYSMENU"
1628  * This was previously done by setting wParam=SC_SIZE + wParam - 2
1629  */
1630  /* But that is not what WinNT does. Instead it sends this. This
1631  * is easy to differentiate from HTSYSMENU, because HTSYSMENU adds
1632  * SC_MOUSEMENU into wParam.
1633  */
1635  break;
1636  }
1637  case HTBORDER:
1638  break;
1639  }
1640  return(0);
1641 }
1642 
1643 
1644 LRESULT
1646 {
1647  ULONG Style;
1648 
1649  Style = pWnd->style;
1650  switch(wParam)
1651  {
1652  case HTCAPTION:
1653  {
1654  /* Maximize/Restore the window */
1655  if((Style & WS_CAPTION) == WS_CAPTION && (Style & WS_MAXIMIZEBOX))
1656  {
1658  }
1659  break;
1660  }
1661  case HTSYSMENU:
1662  {
1663  PMENU SysMenu = IntGetSystemMenu(pWnd, FALSE);
1665 
1666  /* If the close item of the sysmenu is disabled or not present do nothing */
1667  if ((state & (MF_DISABLED | MF_GRAYED)) || (state == 0xFFFFFFFF))
1668  break;
1669 
1671  break;
1672  }
1673  case HTTOP:
1674  case HTBOTTOM:
1675  {
1676  RECT sizingRect = pWnd->rcWindow, mouseRect;
1677 
1678  if (pWnd->ExStyle & WS_EX_MDICHILD)
1679  break;
1680 
1681  UserSystemParametersInfo(SPI_GETWORKAREA, 0, &mouseRect, 0);
1682 
1683  co_WinPosSetWindowPos(pWnd,
1684  NULL,
1685  sizingRect.left,
1686  mouseRect.top,
1687  sizingRect.right - sizingRect.left,
1688  mouseRect.bottom - mouseRect.top,
1689  0);
1690  break;
1691  }
1692  default:
1693  return NC_HandleNCLButtonDown(pWnd, wParam, lParam);
1694  }
1695  return(0);
1696 }
1697 
1698 /***********************************************************************
1699  * NC_HandleNCRButtonDown
1700  *
1701  * Handle a WM_NCRBUTTONDOWN message. Called from DefWindowProc().
1702  */
1704 {
1705  MSG msg;
1706  INT hittest = wParam;
1707 
1708  switch (hittest)
1709  {
1710  case HTCAPTION:
1711  case HTSYSMENU:
1712  if (!IntGetSystemMenu( pwnd, FALSE )) break;
1713 
1715  for (;;)
1716  {
1718  if (IntCallMsgFilter( &msg, MSGF_MAX )) continue;
1719  if (msg.message == WM_RBUTTONUP)
1720  {
1721  hittest = GetNCHitEx( pwnd, msg.pt );
1722  break;
1723  }
1724  if (UserHMGetHandle(pwnd) != IntGetCapture()) return 0;
1725  }
1727 
1728  if (hittest == HTCAPTION || hittest == HTSYSMENU || hittest == HTHSCROLL || hittest == HTVSCROLL)
1729  {
1730  TRACE("Msg pt %x and Msg.lParam %x and lParam %x\n",MAKELONG(msg.pt.x,msg.pt.y),msg.lParam,lParam);
1732  }
1733  break;
1734  }
1735  return 0;
1736 }
1737 
1738 
1739 #if 0 // Old version, kept there for reference, which is also used
1740  // almost unmodified in uxtheme.dll (in nonclient.c)
1741 /*
1742  * FIXME:
1743  * - Check the scrollbar handling
1744  */
1745 LRESULT
1747 {
1748  RECT WindowRect, ClientRect, OrigWndRect;
1749  POINT ClientPoint;
1750  SIZE WindowBorders;
1753 
1754  GetWindowRect(hWnd, &WindowRect);
1755  if (!PtInRect(&WindowRect, Point))
1756  {
1757  return HTNOWHERE;
1758  }
1759  OrigWndRect = WindowRect;
1760 
1762  {
1763  LONG XSize, YSize;
1764 
1765  UserGetWindowBorders(Style, ExStyle, &WindowBorders, FALSE);
1766  InflateRect(&WindowRect, -WindowBorders.cx, -WindowBorders.cy);
1769  if (!PtInRect(&WindowRect, Point))
1770  {
1771  BOOL ThickFrame;
1772 
1773  ThickFrame = (Style & WS_THICKFRAME);
1774  if (Point.y < WindowRect.top)
1775  {
1776  if(Style & WS_MINIMIZE)
1777  return HTCAPTION;
1778  if(!ThickFrame)
1779  return HTBORDER;
1780  if (Point.x < (WindowRect.left + XSize))
1781  return HTTOPLEFT;
1782  if (Point.x >= (WindowRect.right - XSize))
1783  return HTTOPRIGHT;
1784  return HTTOP;
1785  }
1786  if (Point.y >= WindowRect.bottom)
1787  {
1788  if(Style & WS_MINIMIZE)
1789  return HTCAPTION;
1790  if(!ThickFrame)
1791  return HTBORDER;
1792  if (Point.x < (WindowRect.left + XSize))
1793  return HTBOTTOMLEFT;
1794  if (Point.x >= (WindowRect.right - XSize))
1795  return HTBOTTOMRIGHT;
1796  return HTBOTTOM;
1797  }
1798  if (Point.x < WindowRect.left)
1799  {
1800  if(Style & WS_MINIMIZE)
1801  return HTCAPTION;
1802  if(!ThickFrame)
1803  return HTBORDER;
1804  if (Point.y < (WindowRect.top + YSize))
1805  return HTTOPLEFT;
1806  if (Point.y >= (WindowRect.bottom - YSize))
1807  return HTBOTTOMLEFT;
1808  return HTLEFT;
1809  }
1810  if (Point.x >= WindowRect.right)
1811  {
1812  if(Style & WS_MINIMIZE)
1813  return HTCAPTION;
1814  if(!ThickFrame)
1815  return HTBORDER;
1816  if (Point.y < (WindowRect.top + YSize))
1817  return HTTOPRIGHT;
1818  if (Point.y >= (WindowRect.bottom - YSize))
1819  return HTBOTTOMRIGHT;
1820  return HTRIGHT;
1821  }
1822  }
1823  }
1824  else
1825  {
1826  if (ExStyle & WS_EX_STATICEDGE)
1827  InflateRect(&WindowRect,
1830  if (!PtInRect(&WindowRect, Point))
1831  return HTBORDER;
1832  }
1833 
1834  if ((Style & WS_CAPTION) == WS_CAPTION)
1835  {
1836  if (ExStyle & WS_EX_TOOLWINDOW)
1837  WindowRect.top += GetSystemMetrics(SM_CYSMCAPTION);
1838  else
1839  WindowRect.top += GetSystemMetrics(SM_CYCAPTION);
1840  if (!PtInRect(&WindowRect, Point))
1841  {
1842  if (Style & WS_SYSMENU)
1843  {
1844  if (ExStyle & WS_EX_TOOLWINDOW)
1845  {
1846  WindowRect.right -= GetSystemMetrics(SM_CXSMSIZE);
1847  }
1848  else
1849  {
1850  // if(!(ExStyle & WS_EX_DLGMODALFRAME))
1851  // FIXME: The real test should check whether there is
1852  // an icon for the system window, and if so, do the
1853  // rect.left increase.
1854  // See dll/win32/uxtheme/nonclient.c!DefWndNCHitTest
1855  // and win32ss/user/ntuser/nonclient.c!GetNCHitEx which does
1856  // the test better.
1857  WindowRect.left += GetSystemMetrics(SM_CXSIZE);
1858  WindowRect.right -= GetSystemMetrics(SM_CXSIZE);
1859  }
1860  }
1861  if (Point.x < WindowRect.left)
1862  return HTSYSMENU;
1863  if (WindowRect.right <= Point.x)
1864  return HTCLOSE;
1866  WindowRect.right -= GetSystemMetrics(SM_CXSIZE);
1867  if (Point.x >= WindowRect.right)
1868  return HTMAXBUTTON;
1869  if (Style & WS_MINIMIZEBOX)
1870  WindowRect.right -= GetSystemMetrics(SM_CXSIZE);
1871  if (Point.x >= WindowRect.right)
1872  return HTMINBUTTON;
1873  return HTCAPTION;
1874  }
1875  }
1876 
1877  if(!(Style & WS_MINIMIZE))
1878  {
1879  ClientPoint = Point;
1880  ScreenToClient(hWnd, &ClientPoint);
1881  GetClientRect(hWnd, &ClientRect);
1882 
1883  if (PtInRect(&ClientRect, ClientPoint))
1884  {
1885  return HTCLIENT;
1886  }
1887 
1888  if (GetMenu(hWnd) && !(Style & WS_CHILD))
1889  {
1890  if (Point.x > 0 && Point.x < WindowRect.right && ClientPoint.y < 0)
1891  return HTMENU;
1892  }
1893 
1894  if (ExStyle & WS_EX_CLIENTEDGE)
1895  {
1896  InflateRect(&WindowRect, -2 * GetSystemMetrics(SM_CXBORDER),
1898  }
1899 
1900  if ((Style & WS_VSCROLL) && (Style & WS_HSCROLL) &&
1901  (WindowRect.bottom - WindowRect.top) > GetSystemMetrics(SM_CYHSCROLL))
1902  {
1903  RECT ParentRect, TempRect = WindowRect, TempRect2 = WindowRect;
1905 
1906  TempRect.bottom -= GetSystemMetrics(SM_CYHSCROLL);
1907  if ((ExStyle & WS_EX_LEFTSCROLLBAR) != 0)
1908  TempRect.right = TempRect.left + GetSystemMetrics(SM_CXVSCROLL);
1909  else
1910  TempRect.left = TempRect.right - GetSystemMetrics(SM_CXVSCROLL);
1911  if (PtInRect(&TempRect, Point))
1912  return HTVSCROLL;
1913 
1914  TempRect2.top = TempRect2.bottom - GetSystemMetrics(SM_CYHSCROLL);
1915  if ((ExStyle & WS_EX_LEFTSCROLLBAR) != 0)
1916  TempRect2.left += GetSystemMetrics(SM_CXVSCROLL);
1917  else
1918  TempRect2.right -= GetSystemMetrics(SM_CXVSCROLL);
1919  if (PtInRect(&TempRect2, Point))
1920  return HTHSCROLL;
1921 
1922  TempRect.top = TempRect2.top;
1923  TempRect.bottom = TempRect2.bottom;
1924  if(Parent)
1925  GetClientRect(Parent, &ParentRect);
1926  if (PtInRect(&TempRect, Point) && HASSIZEGRIP(Style, ExStyle,
1927  GetWindowLongPtrW(Parent, GWL_STYLE), OrigWndRect, ParentRect))
1928  {
1929  if ((ExStyle & WS_EX_LEFTSCROLLBAR) != 0)
1930  return HTBOTTOMLEFT;
1931  else
1932  return HTBOTTOMRIGHT;
1933  }
1934  }
1935  else
1936  {
1937  if (Style & WS_VSCROLL)
1938  {
1939  RECT TempRect = WindowRect;
1940 
1941  if ((ExStyle & WS_EX_LEFTSCROLLBAR) != 0)
1942  TempRect.right = TempRect.left + GetSystemMetrics(SM_CXVSCROLL);
1943  else
1944  TempRect.left = TempRect.right - GetSystemMetrics(SM_CXVSCROLL);
1945  if (PtInRect(&TempRect, Point))
1946  return HTVSCROLL;
1947  } else
1948  if (Style & WS_HSCROLL)
1949  {
1950  RECT TempRect = WindowRect;
1951  TempRect.top = TempRect.bottom - GetSystemMetrics(SM_CYHSCROLL);
1952  if (PtInRect(&TempRect, Point))
1953  return HTHSCROLL;
1954  }
1955  }
1956  }
1957 
1958  return HTNOWHERE;
1959 }
1960 #endif
1961 
1964 {
1965  RECT rcWindow, rcClient;
1966  DWORD Style, ExStyle;
1967 
1968  if (!pWnd) return HTNOWHERE;
1969 
1970  if (UserIsDesktopWindow(pWnd))
1971  {
1972  rcClient.left = rcClient.top = rcWindow.left = rcWindow.top = 0;
1977  }
1978  else
1979  {
1980  rcClient = pWnd->rcClient;
1981  rcWindow = pWnd->rcWindow;
1982  }
1983 
1984  if (!RECTL_bPointInRect(&rcWindow, pt.x, pt.y)) return HTNOWHERE;
1985 
1986  Style = pWnd->style;
1987  ExStyle = pWnd->ExStyle;
1988 
1989  if (Style & WS_MINIMIZE) return HTCAPTION;
1990 
1991  if (RECTL_bPointInRect( &rcClient, pt.x, pt.y )) return HTCLIENT;
1992 
1993  /* Check borders */
1994  if (HAS_THICKFRAME( Style, ExStyle ))
1995  {
1997  if (!RECTL_bPointInRect(&rcWindow, pt.x, pt.y ))
1998  {
1999  /* Check top sizing border */
2000  if (pt.y < rcWindow.top)
2001  {
2002  if (pt.x < rcWindow.left+UserGetSystemMetrics(SM_CXSIZE)) return HTTOPLEFT;
2003  if (pt.x >= rcWindow.right-UserGetSystemMetrics(SM_CXSIZE)) return HTTOPRIGHT;
2004  return HTTOP;
2005  }
2006  /* Check bottom sizing border */
2007  if (pt.y >= rcWindow.bottom)
2008  {
2009  if (pt.x < rcWindow.left+UserGetSystemMetrics(SM_CXSIZE)) return HTBOTTOMLEFT;
2010  if (pt.x >= rcWindow.right-UserGetSystemMetrics(SM_CXSIZE)) return HTBOTTOMRIGHT;
2011  return HTBOTTOM;
2012  }
2013  /* Check left sizing border */
2014  if (pt.x < rcWindow.left)
2015  {
2016  if (pt.y < rcWindow.top+UserGetSystemMetrics(SM_CYSIZE)) return HTTOPLEFT;
2017  if (pt.y >= rcWindow.bottom-UserGetSystemMetrics(SM_CYSIZE)) return HTBOTTOMLEFT;
2018  return HTLEFT;
2019  }
2020  /* Check right sizing border */
2021  if (pt.x >= rcWindow.right)
2022  {
2023  if (pt.y < rcWindow.top+UserGetSystemMetrics(SM_CYSIZE)) return HTTOPRIGHT;
2024  if (pt.y >= rcWindow.bottom-UserGetSystemMetrics(SM_CYSIZE)) return HTBOTTOMRIGHT;
2025  return HTRIGHT;
2026  }
2027  }
2028  }
2029  else /* No thick frame */
2030  {
2031  if (HAS_DLGFRAME( Style, ExStyle ))
2033  else if (HAS_THINFRAME( Style, ExStyle ))
2035  else if (HAS_CLIENTFRAME( Style, ExStyle ))
2037  if (!RECTL_bPointInRect( &rcWindow, pt.x, pt.y )) return HTBORDER;
2038  }
2039 
2040  /* Check caption */
2041 
2042  if ((Style & WS_CAPTION) == WS_CAPTION)
2043  {
2044  if (ExStyle & WS_EX_TOOLWINDOW)
2045  rcWindow.top += UserGetSystemMetrics(SM_CYSMCAPTION) - 1;
2046  else
2047  rcWindow.top += UserGetSystemMetrics(SM_CYCAPTION) - 1;
2048  if (!RECTL_bPointInRect( &rcWindow, pt.x, pt.y ))
2049  {
2050  BOOL min_or_max_box = (Style & WS_SYSMENU) && (Style & (WS_MINIMIZEBOX|WS_MAXIMIZEBOX));
2051  if (ExStyle & WS_EX_LAYOUTRTL)
2052  {
2053  /* Check system menu */
2054  if ((Style & WS_SYSMENU) && !(ExStyle & WS_EX_TOOLWINDOW) && NC_IconForWindow(pWnd))
2055  {
2056  rcWindow.right -= UserGetSystemMetrics(SM_CYCAPTION) - 1;
2057  if (pt.x > rcWindow.right) return HTSYSMENU;
2058  }
2059 
2060  /* Check close button */
2061  if (Style & WS_SYSMENU)
2062  {
2063  rcWindow.left += UserGetSystemMetrics(SM_CYCAPTION);
2064  if (pt.x < rcWindow.left) return HTCLOSE;
2065  }
2066 
2067  /* Check maximize box */
2068  /* In Win95 there is automatically a Maximize button when there is a minimize one */
2069  if (min_or_max_box && !(ExStyle & WS_EX_TOOLWINDOW))
2070  {
2071  rcWindow.left += UserGetSystemMetrics(SM_CXSIZE);
2072  if (pt.x < rcWindow.left) return HTMAXBUTTON;
2073  }
2074 
2075  /* Check minimize box */
2076  if (min_or_max_box && !(ExStyle & WS_EX_TOOLWINDOW))
2077  {
2078  rcWindow.left += UserGetSystemMetrics(SM_CXSIZE);
2079  if (pt.x < rcWindow.left) return HTMINBUTTON;
2080  }
2081  }
2082  else
2083  {
2084  /* Check system menu */
2085  if ((Style & WS_SYSMENU) && !(ExStyle & WS_EX_TOOLWINDOW) && NC_IconForWindow(pWnd))
2086  {
2087  rcWindow.left += UserGetSystemMetrics(SM_CYCAPTION) - 1;
2088  if (pt.x < rcWindow.left) return HTSYSMENU;
2089  }
2090 
2091  /* Check close button */
2092  if (Style & WS_SYSMENU)
2093  {
2095  if (pt.x > rcWindow.right) return HTCLOSE;
2096  }
2097 
2098  /* Check maximize box */
2099  /* In Win95 there is automatically a Maximize button when there is a minimize one */
2100  if (min_or_max_box && !(ExStyle & WS_EX_TOOLWINDOW))
2101  {
2102  rcWindow.right -= UserGetSystemMetrics(SM_CXSIZE);
2103  if (pt.x > rcWindow.right) return HTMAXBUTTON;
2104  }
2105 
2106  /* Check minimize box */
2107  if (min_or_max_box && !(ExStyle & WS_EX_TOOLWINDOW))
2108  {
2109  rcWindow.right -= UserGetSystemMetrics(SM_CXSIZE);
2110  if (pt.x > rcWindow.right) return HTMINBUTTON;
2111  }
2112  }
2113  return HTCAPTION;
2114  }
2115  }
2116 
2117  /* Check menu bar */
2118 
2119  if (HAS_MENU( pWnd, Style ) && (pt.y < rcClient.top) &&
2120  (pt.x >= rcClient.left) && (pt.x < rcClient.right))
2121  return HTMENU;
2122 
2123  /* Check vertical scroll bar */
2124 
2126  if (Style & WS_VSCROLL)
2127  {
2128  if((ExStyle & WS_EX_LEFTSCROLLBAR) != 0)
2129  rcClient.left -= UserGetSystemMetrics(SM_CXVSCROLL);
2130  else
2132  if (RECTL_bPointInRect( &rcClient, pt.x, pt.y )) return HTVSCROLL;
2133  }
2134 
2135  /* Check horizontal scroll bar */
2136 
2137  if (Style & WS_HSCROLL)
2138  {
2140  if (RECTL_bPointInRect( &rcClient, pt.x, pt.y ))
2141  {
2142  /* Check size box */
2143  if ((Style & WS_VSCROLL) &&
2144  ((((ExStyle & WS_EX_LEFTSCROLLBAR) != 0) && (pt.x <= rcClient.left + UserGetSystemMetrics(SM_CXVSCROLL))) ||
2145  (((ExStyle & WS_EX_LEFTSCROLLBAR) == 0) && (pt.x >= rcClient.right - UserGetSystemMetrics(SM_CXVSCROLL)))))
2146  return HTSIZE;
2147  return HTHSCROLL;
2148  }
2149  }
2150 
2151  /* Has to return HTNOWHERE if nothing was found
2152  Could happen when a window has a customized non client area */
2153  return HTNOWHERE;
2154 }
2155 
2156 /* EOF */
#define BF_FLAT
Definition: winuser.h:471
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
PUSER_MESSAGE_QUEUE gpqForeground
Definition: focus.c:13
#define HTMAXBUTTON
Definition: winuser.h:2474
#define HTTOP
Definition: winuser.h:2480
__kernel_entry W32KAPI HRGN APIENTRY NtGdiCreateRectRgn(_In_ INT xLeft, _In_ INT yTop, _In_ INT xRight, _In_ INT yBottom)
#define WS_THICKFRAME
Definition: pedump.c:630
#define MSGF_MAX
Definition: winuser.h:1172
#define HTLEFT
Definition: winuser.h:2477
GLint GLint GLsizei width
Definition: gl.h:1546
#define MSQ_STATE_MOVESIZE
Definition: ntuser.h:3703
#define max(a, b)
Definition: svc.c:63
DWORD ExStyle
Definition: ntuser.h:699
BOOL WINAPI InflateRect(_Inout_ LPRECT, _In_ int, _In_ int)
static HICON
Definition: imagelist.c:84
#define HTHSCROLL
Definition: winuser.h:2471
BOOL UserDrawIconEx(HDC hDc, INT xLeft, INT yTop, PCURICON_OBJECT pIcon, INT cxWidth, INT cyHeight, UINT istepIfAniCur, HBRUSH hbrFlickerFreeDraw, UINT diFlags)
Definition: cursoricon.c:1688
#define MF_DISABLED
Definition: winuser.h:130
#define SM_CYHSCROLL
Definition: winuser.h:956
BOOL NTAPI GreDeleteObject(HGDIOBJ hobj)
Definition: gdiobj.c:1158
#define TIF_MOVESIZETRACKING
Definition: ntuser.h:277
void IntDrawScrollBar(PWND, HDC, INT)
Definition: scrollbar.c:1180
#define COLOR_WINDOWFRAME
Definition: winuser.h:913
#define STATE_SYSTEM_OFFSCREEN
Definition: winuser.h:2868
#define WM_MOUSEFIRST
Definition: winuser.h:1764
#define PATINVERT
Definition: wingdi.h:328
static HBRUSH hbrush
#define SM_CYSIZE
Definition: winuser.h:986
BOOL NTAPI GreIsHandleValid(HGDIOBJ hobj)
Definition: gdiobj.c:1146
#define MF_BYCOMMAND
Definition: winuser.h:202
#define SC_RESTORE
Definition: winuser.h:2588
long y
Definition: polytest.cpp:48
BOOL FASTCALL IntClientToScreen(PWND Wnd, LPPOINT lpPoint)
Definition: winpos.c:198
#define WM_CONTEXTMENU
Definition: richedit.h:64
#define DC_NOVISIBLE
Definition: undocuser.h:147
__kernel_entry W32KAPI BOOL APIENTRY NtGdiPatBlt(_In_ HDC hdcDest, _In_ INT x, _In_ INT y, _In_ INT cx, _In_ INT cy, _In_ DWORD dwRop)
Definition: bitblt.c:984
FORCEINLINE VOID RECTL_vSetEmptyRect(_Out_ RECTL *prcl)
Definition: rect.h:20
PCURICON_OBJECT FASTCALL UserGetCurIconObject(HCURSOR hCurIcon)
Definition: cursoricon.c:200
LRESULT FASTCALL IntDispatchMessage(PMSG pMsg)
Definition: message.c:841
HGDIOBJ FASTCALL IntGetSysColorBrush(INT Object)
Definition: stockobj.c:317
PVOID UserGetObjectNoErr(PUSER_HANDLE_TABLE ht, HANDLE handle, HANDLE_TYPE type)
Definition: object.c:481
#define UserIsDesktopWindow(pWnd)
Definition: desktop.h:194
long x
Definition: polytest.cpp:48
BOOL FASTCALL IntReleaseCapture(VOID)
Definition: focus.c:1530
#define SB_VERT
Definition: winuser.h:553
VOID FASTCALL RECTL_vInflateRect(_Inout_ RECTL *rect, _In_ INT dx, _In_ INT dy)
Definition: rect.c:101
#define TRUE
Definition: types.h:120
#define pt(x, y)
Definition: drawing.c:79
HWND FASTCALL UserGetActiveWindow(VOID)
Definition: focus.c:1429
_In_ HFONT _Out_ PUINT _Out_ PUINT Width
Definition: font.h:124
#define ERROR(name)
Definition: error_private.h:53
#define WNDS_HASHORIZONTALSCROLLBAR
Definition: ntuser.h:602
BOOL FASTCALL IntTranslateKbdMessage(LPMSG lpMsg, UINT flags)
Definition: keyboard.c:1152
GLint dy
Definition: linetemp.h:97
BOOL IntIsScrollBarVisible(PWND pWnd, INT hBar)
Definition: nonclient.c:768
FLONG TIF_flags
Definition: win32.h:95
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
#define SB_HORZ
Definition: winuser.h:552
VOID FASTCALL IntNotifyWinEvent(DWORD Event, PWND pWnd, LONG idObject, LONG idChild, DWORD flags)
Definition: event.c:179
__kernel_entry W32KAPI HANDLE APIENTRY NtGdiGetStockObject(_In_ INT iObject)
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
BOOLEAN FASTCALL co_WinPosSetWindowPos(PWND Window, HWND WndInsertAfter, INT x, INT y, INT cx, INT cy, UINT flags)
Definition: winpos.c:1748
static HDC
Definition: imagelist.c:92
#define DFCS_INACTIVE
Definition: winuser.h:502
PSERVERINFO gpsi
Definition: imm.c:18
#define OBJID_WINDOW
Definition: winable.h:15
HWND hWnd
Definition: settings.c:17
LONG top
Definition: windef.h:307
#define WS_EX_LAYOUTRTL
Definition: winuser.h:390
HANDLE HWND
Definition: compat.h:19
#define COLOR_INACTIVEBORDER
Definition: winuser.h:918
static HRGN hRgn
Definition: mapping.c:33
#define CS_NOCLOSE
Definition: winuser.h:649
void FASTCALL NC_GetSysPopupPos(PWND Wnd, RECT *Rect)
Definition: nonclient.c:117
#define DCX_USESTYLE
Definition: GetDCEx.c:10
#define WS_DLGFRAME
Definition: pedump.c:626
#define VK_LEFT
Definition: winuser.h:2214
#define WM_EXITSIZEMOVE
Definition: winuser.h:1814
#define COLOR_INACTIVECAPTION
Definition: winuser.h:910
#define COLOR_CAPTIONTEXT
Definition: winuser.h:916
#define CS_HREDRAW
Definition: winuser.h:648
#define COLOR_BTNHIGHLIGHT
Definition: winuser.h:929
HDC FASTCALL UserGetWindowDC(PWND Wnd)
Definition: windc.c:947
#define GWL_EXSTYLE
Definition: winuser.h:845
#define SM_CXEDGE
Definition: winuser.h:1002
int UserShowCursor(BOOL bShow)
Definition: msgqueue.c:168
#define SM_CYSMICON
Definition: winuser.h:1007
BOOL UserHasWindowEdge(DWORD Style, DWORD ExStyle)
Definition: nonclient.c:36
HDC FASTCALL UserGetDCEx(PWND Window OPTIONAL, HANDLE ClipRegion, ULONG Flags)
#define HTBOTTOMLEFT
Definition: winuser.h:2484
#define SC_MOUSEMENU
Definition: winuser.h:2585
BOOL FASTCALL UserDereferenceObject(PVOID Object)
Definition: object.c:644
BOOL WINAPI DrawFrameControl(_In_ HDC, _Inout_ LPRECT, _In_ UINT, _In_ UINT)
BOOL FASTCALL IntCallMsgFilter(LPMSG lpmsg, INT code)
Definition: message.c:2137
UINT_PTR WPARAM
Definition: windef.h:207
#define VK_DOWN
Definition: winuser.h:2217
#define HTRIGHT
Definition: winuser.h:2479
#define WS_CHILD
Definition: pedump.c:617
_In_ HFONT _Out_ PUINT Height
Definition: font.h:124
RECT rcClient
Definition: ntuser.h:712
#define GetWindowLongPtrW
Definition: winuser.h:4819
LONG left
Definition: windef.h:306
VOID FASTCALL IntGetClientRect(PWND WindowObject, RECTL *Rect)
Definition: winpos.c:91
HICON HCURSOR
Definition: windef.h:299
#define SM_CYFRAME
Definition: winuser.h:990
VOID UserDrawCaptionButtonWnd(PWND pWnd, HDC hDC, BOOL bDown, ULONG Type)
Definition: nonclient.c:868
#define SM_CXFRAME
Definition: winuser.h:988
UINT MENU_DrawMenuBar(HDC hDC, LPRECT lprect, PWND pWnd, BOOL suppress_draw)
Definition: menu.c:2744
#define VK_ESCAPE
Definition: winuser.h:2204
#define WS_CLIPCHILDREN
Definition: pedump.c:619
LONG right
Definition: windef.h:308
VOID UserDrawCaptionButton(PWND pWnd, LPRECT Rect, DWORD Style, DWORD ExStyle, HDC hDC, BOOL bDown, ULONG Type)
Definition: nonclient.c:786
#define WS_EX_LEFTSCROLLBAR
Definition: winuser.h:392
#define FASTCALL
Definition: nt_native.h:50
#define HTNOWHERE
Definition: winuser.h:2464
#define WS_EX_TOOLWINDOW
Definition: winuser.h:404
BOOL UserSetCursorPos(INT x, INT y, DWORD flags, ULONG_PTR dwExtraInfo, BOOL Hook)
Definition: cursoricon.c:238
int32_t INT
Definition: typedefs.h:58
#define VK_RETURN
Definition: winuser.h:2191
#define HTMINBUTTON
Definition: winuser.h:2473
struct _CURICON_OBJECT * spicn
Definition: ntuser.h:580
& rect
Definition: startmenu.cpp:1413
WPARAM wParam
Definition: combotst.c:138
#define HTTOPLEFT
Definition: winuser.h:2481
#define DCX_WINDOW
Definition: winuser.h:2103
#define BF_ADJUST
Definition: winuser.h:470
__kernel_entry W32KAPI HBRUSH APIENTRY NtGdiSelectBrush(_In_ HDC hdc, _In_ HBRUSH hbrush)
#define DC_ICON
Definition: winuser.h:429
FORCEINLINE PMENU UserGetMenuObject(HMENU hMenu)
Definition: userfuncs.h:4
#define RGN_AND
Definition: wingdi.h:356
#define HAS_CLIENTFRAME(Style, ExStyle)
Definition: window.h:19
#define BF_RECT
Definition: winuser.h:462
#define DFCS_PUSHED
Definition: winuser.h:503
static LRESULT DefWndNCHitTest(HWND hWnd, POINT Point)
Definition: nonclient.c:792
#define WM_QUERYDRAGICON
Definition: winuser.h:1644
#define SM_CXSCREEN
Definition: winuser.h:953
__kernel_entry W32KAPI BOOL APIENTRY NtGdiLineTo(_In_ HDC hdc, _In_ INT x, _In_ INT y)
__kernel_entry W32KAPI HPEN APIENTRY NtGdiSelectPen(_In_ HDC hdc, _In_ HPEN hpen)
#define ON_RIGHT_BORDER(hit)
Definition: nonclient.c:27
#define WS_EX_MDICHILD
Definition: winuser.h:394
#define L(x)
Definition: ntvdm.h:50
#define COLOR_3DFACE
Definition: winuser.h:923
#define WNDS_HASVERTICALSCROOLLBAR
Definition: ntuser.h:601
#define HTSYSMENU
Definition: winuser.h:2467
UINT style
Definition: ntuser.h:575
#define VK_UP
Definition: winuser.h:2215
#define BDR_SUNKENINNER
Definition: winuser.h:445
#define DC_NC
Definition: winuser.h:440
#define FALSE
Definition: types.h:117
#define WS_MINIMIZE
Definition: pedump.c:622
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
#define WM_SETCURSOR
Definition: winuser.h:1626
#define GA_PARENT
Definition: winuser.h:2778
#define MSGF_SIZE
Definition: winuser.h:1167
BOOL WINAPI DrawEdge(_In_ HDC, _Inout_ LPRECT, _In_ UINT, _In_ UINT)
#define SM_CYDLGFRAME
Definition: winuser.h:962
#define DC_REDRAWHUNGWND
Definition: undocuser.h:152
ULONG cyMenu
Definition: ntuser.h:418
#define CHILDID_SELF
Definition: winable.h:14
#define SC_MAXIMIZE
Definition: winuser.h:2578
LRESULT NC_DoNCPaint(PWND pWnd, HDC hDC, INT Flags)
Definition: nonclient.c:1075
#define GreCreateRectRgnIndirect(prc)
Definition: region.h:96
#define WM_SIZING
Definition: winuser.h:1797
THRDESKHEAD head
Definition: ntuser.h:690
struct _CURICON_OBJECT * spicnSm
Definition: ntuser.h:585
#define MAKELONG(a, b)
Definition: typedefs.h:249
BOOL UserDrawSysMenuButton(PWND pWnd, HDC hDC, LPRECT Rect, BOOL Down)
Definition: nonclient.c:745
VOID FASTCALL UserDrawMovingFrame(HDC hdc, RECTL *rect, BOOL thickframe)
Definition: nonclient.c:56
#define HAS_THINFRAME(Style, ExStyle)
Definition: window.h:16
#define HAS_THICKFRAME(Style, ExStyle)
Definition: window.h:12
#define WS_EX_DLGMODALFRAME
Definition: pedump.c:645
HRGN hrgnClip
Definition: ntuser.h:728
#define COLOR_ACTIVECAPTION
Definition: winuser.h:909
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
LONG cx
Definition: windef.h:334
#define WM_KEYDOWN
Definition: winuser.h:1705
LONG_PTR LPARAM
Definition: windef.h:208
#define SM_CYEDGE
Definition: winuser.h:1003
#define WH_CBT
Definition: winuser.h:35
#define WS_EX_NOACTIVATE
Definition: winuser.h:395
#define DFCS_CAPTIONRESTORE
Definition: winuser.h:483
#define WS_MAXIMIZEBOX
Definition: pedump.c:632
VOID UserGetWindowBorders(DWORD Style, DWORD ExStyle, SIZE *Size, BOOL WithClient)
Definition: nonclient.c:53
PCURICON_OBJECT FASTCALL NC_IconForWindow(PWND pWnd)
Definition: nonclient.c:714
BOOL APIENTRY UserClipCursor(RECTL *prcl)
Definition: cursoricon.c:700
#define DC_ACTIVE
Definition: winuser.h:427
LONG NTAPI UserGetSystemMetrics(ULONG Index)
Definition: metric.c:208
UINT FASTCALL co_WinPosGetMinMaxInfo(PWND Window, POINT *MaxSize, POINT *MaxPos, POINT *MinTrack, POINT *MaxTrack)
Definition: winpos.c:933
#define WS_MINIMIZED
Definition: undocuser.h:18
DWORD rgstate[CCHILDREN_SCROLLBAR+1]
Definition: winuser.h:3744
#define UserHMGetHandle(obj)
Definition: ntuser.h:230
#define WS_CAPTION
Definition: pedump.c:624
#define HTSIZE
Definition: winuser.h:2469
#define CS_VREDRAW
Definition: winuser.h:653
#define SM_CYSMSIZE
Definition: winuser.h:1010
#define SM_CYSCREEN
Definition: winuser.h:954
HWND FASTCALL MsqSetStateWindow(PTHREADINFO pti, ULONG Type, HWND hWnd)
Definition: msgqueue.c:2551
UINT_PTR IDMenu
Definition: ntuser.h:726
#define TRACE(s)
Definition: solgame.cpp:4
HWND FASTCALL co_UserSetCapture(HWND hWnd)
Definition: focus.c:1458
#define ON_BOTTOM_BORDER(hit)
Definition: nonclient.c:31
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
LONG FASTCALL DefWndStartSizeMove(PWND Wnd, WPARAM wParam, POINT *capturePoint)
Definition: nonclient.c:140
#define HTTOPRIGHT
Definition: winuser.h:2482
#define SM_CYCAPTION
Definition: winuser.h:957
const DWORD Style
Definition: appswitch.c:71
#define OBJID_HSCROLL
Definition: winable.h:21
#define ASSERT(a)
Definition: mode.c:44
r parent
Definition: btrfs.c:3010
PMENU FASTCALL IntGetSystemMenu(PWND Window, BOOL bRevert)
Definition: menu.c:5383
#define WS_ICONIC
Definition: pedump.c:641
#define UserHasDlgFrameStyle(Style, ExStyle)
Definition: nonclient.c:14
#define SM_CXDLGFRAME
Definition: winuser.h:960
#define SWP_NOACTIVATE
Definition: winuser.h:1232
#define UlongToHandle(ul)
Definition: basetsd.h:97
#define DFCS_SCROLLSIZEGRIP
Definition: winuser.h:494
#define DC_FRAME
Definition: undocuser.h:149
#define WM_MOUSELAST
Definition: winuser.h:1791
#define DFCS_CAPTIONCLOSE
Definition: winuser.h:480
BOOL FASTCALL co_IntGetScrollBarInfo(PWND, LONG, PSCROLLBARINFO)
Definition: scrollbar.c:760
VOID NC_DrawFrame(HDC hDC, RECT *CurrentRect, BOOL Active, DWORD Style, DWORD ExStyle)
Definition: nonclient.c:887
HANDLE FASTCALL UserGetProp(_In_ PWND Window, _In_ ATOM Atom, _In_ BOOLEAN SystemProp)
Definition: prop.c:46
#define SM_CXSMSIZE
Definition: winuser.h:1009
#define COLOR_ACTIVEBORDER
Definition: winuser.h:917
unsigned short WORD
Definition: ntddk_ex.h:93
Type
Definition: Type.h:6
int WINAPI GetSystemMetrics(_In_ int)
#define HTBOTTOM
Definition: winuser.h:2483
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD FASTCALL IntGetSysColor(INT nIndex)
Definition: stockobj.c:323
VOID FASTCALL co_IntUpdateWindows(PWND Wnd, ULONG Flags, BOOL Recurse)
Definition: painting.c:519
BOOL FASTCALL IntIsWindow(HWND hWnd)
Definition: window.c:188
#define OBJID_VSCROLL
Definition: winable.h:20
#define WVR_VALIDRECTS
Definition: winuser.h:2512
#define WM_RBUTTONUP
Definition: winuser.h:1770
#define WS_HSCROLL
Definition: pedump.c:628
#define SM_CXSMICON
Definition: winuser.h:1006
#define WM_MDIGETACTIVE
Definition: winuser.h:1811
#define HTCLOSE
Definition: winuser.h:2489
LRESULT APIENTRY co_HOOK_CallHooks(INT HookId, INT Code, WPARAM wParam, LPARAM lParam)
Definition: hook.c:1103
FORCEINLINE BOOL RECTL_bPointInRect(_In_ const RECTL *prcl, _In_ INT x, _In_ INT y)
Definition: rect.h:52
PWND FASTCALL UserGetDesktopWindow(VOID)
Definition: desktop.c:1386
#define SM_CYBORDER
Definition: winuser.h:959
LRESULT NC_HandleNCCalcSize(PWND Wnd, WPARAM wparam, RECTL *Rect, BOOL Suspended)
Definition: nonclient.c:1282
void FASTCALL NC_GetInsideRect(PWND Wnd, RECT *rect)
Definition: nonclient.c:71
struct Point Point
BOOL FASTCALL IntIsWindowVisible(PWND Wnd)
Definition: window.c:201
#define WM_MOVING
Definition: winuser.h:1799
LRESULT FASTCALL co_IntSendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
Definition: message.c:1446
#define UserHasThinFrameStyle(Style, ExStyle)
Definition: nonclient.c:22
HDC hdc
Definition: main.c:9
#define COLOR_BTNFACE
Definition: winuser.h:922
COLORREF FASTCALL IntSetDCPenColor(HDC, COLORREF)
Definition: dcutil.c:259
static int state
Definition: maze.c:121
#define COLOR_INACTIVECAPTIONTEXT
Definition: winuser.h:928
#define SM_CXBORDER
Definition: winuser.h:958
#define DI_NORMAL
Definition: wingdi.h:72
#define WS_EX_TOPMOST
Definition: pedump.c:647
#define WM_SETVISIBLE
Definition: undocuser.h:31
#define WNDS_ACTIVEFRAME
Definition: ntuser.h:606
RECT rcWindow
Definition: ntuser.h:711
ATOM atomIconProp
Definition: ntuser.h:1061
#define HTBOTTOMRIGHT
Definition: winuser.h:2485
BOOL FASTCALL GreMoveTo(HDC hdc, INT x, INT y, LPPOINT pptOut)
Definition: line.c:108
HWND APIENTRY IntGetCapture(VOID)
Definition: focus.c:1440
#define DFC_CAPTION
Definition: winuser.h:473
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
__kernel_entry W32KAPI INT APIENTRY NtGdiCombineRgn(_In_ HRGN hrgnDst, _In_ HRGN hrgnSrc1, _In_opt_ HRGN hrgnSrc2, _In_ INT iMode)
PWND FASTCALL UserGetAncestor(PWND Wnd, UINT Type)
Definition: window.c:3335
#define PATCOPY
Definition: wingdi.h:335
POINT ptLast
Definition: win32.h:129
#define RGN_COPY
Definition: wingdi.h:357
#define VK_RIGHT
Definition: winuser.h:2216
#define EDGE_RAISED
Definition: winuser.h:450
#define SC_MINIMIZE
Definition: winuser.h:2576
#define SWP_NOSIZE
Definition: winuser.h:1235
#define ERR(fmt,...)
Definition: debug.h:110
#define HTCAPTION
Definition: winuser.h:2466
#define GWL_STYLE
Definition: winuser.h:846
Definition: ntuser.h:688
VOID FASTCALL UpdateThreadWindows(PWND pWnd, PTHREADINFO pti, HRGN hRgn)
Definition: painting.c:1093
FORCEINLINE VOID RECTL_vOffsetRect(_Inout_ RECTL *prcl, _In_ INT cx, _In_ INT cy)
Definition: rect.h:31
LRESULT NC_HandleNCLButtonDblClk(PWND pWnd, WPARAM wParam, LPARAM lParam)
Definition: nonclient.c:1645
static HDC hDC
Definition: 3dtext.c:33
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
FORCEINLINE VOID RECTL_vSetRect(_Out_ RECTL *prcl, _In_ LONG left, _In_ LONG top, _In_ LONG right, _In_ LONG bottom)
Definition: rect.h:5
VOID UserDrawCaptionBar(PWND pWnd, HDC hDC, INT Flags)
Definition: nonclient.c:933
#define DCX_CACHE
Definition: winuser.h:2104
HWND WINAPI GetParent(_In_ HWND)
#define DC_NOSENDMSG
Definition: undocuser.h:148
#define WS_BORDER
Definition: pedump.c:625
#define HAS_MENU(hwnd, style)
Definition: uxthemep.h:222
BOOL APIENTRY co_IntGetPeekMessage(PMSG pMsg, HWND hWnd, UINT MsgFilterMin, UINT MsgFilterMax, UINT RemoveMsg, BOOL bGMSG)
Definition: message.c:1177
#define WS_EX_CLIENTEDGE
Definition: winuser.h:384
#define DC_SMALLCAP
Definition: winuser.h:428
#define WS_MINIMIZEBOX
Definition: pedump.c:631
#define RGN_DIFF
Definition: wingdi.h:358
BOOL FASTCALL co_UserRedrawWindow(PWND Window, const RECTL *UpdateRect, PREGION UpdateRgn, ULONG Flags)
Definition: painting.c:888
HICON hIcon
Definition: msconfig.c:44
VOID FASTCALL DefWndDoSizeMove(PWND pwnd, WORD wParam)
Definition: nonclient.c:239
#define RDW_ALLCHILDREN
Definition: winuser.h:1211
#define HTMENU
Definition: winuser.h:2470
#define WVR_HREDRAW
Definition: winuser.h:2509
FORCEINLINE BOOL IntEqualRect(RECTL *lprc1, RECTL *lprc2)
Definition: winpos.h:48
VOID FASTCALL UserDrawWindowFrame(HDC hdc, RECTL *rect, ULONG width, ULONG height)
Definition: nonclient.c:42
#define SC_SIZE
Definition: winuser.h:2574
#define COLOR_BTNSHADOW
Definition: winuser.h:924
#define WM_LBUTTONUP
Definition: winuser.h:1767
PWND FASTCALL IntGetParent(PWND Wnd)
Definition: window.c:216
DWORD state
Definition: ntuser.h:696
#define HTBORDER
Definition: winuser.h:2487
struct tagSCROLLBARINFO SCROLLBARINFO
INT FASTCALL IntMapWindowPoints(PWND FromWnd, PWND ToWnd, LPPOINT lpPoints, UINT cPoints)
Definition: winpos.c:143
#define ON_TOP_BORDER(hit)
Definition: nonclient.c:29
LRESULT NC_HandleNCRButtonDown(PWND pwnd, WPARAM wParam, LPARAM lParam)
Definition: nonclient.c:1703
#define min(a, b)
Definition: monoChain.cc:55
#define WS_POPUP
Definition: pedump.c:616
unsigned int UINT
Definition: ndis.h:50
#define WM_MOUSEMOVE
Definition: winuser.h:1765
#define NULL
Definition: types.h:112
ATOM atomIconSmProp
Definition: ntuser.h:1060
#define WS_VSCROLL
Definition: pedump.c:627
static INT NC_DoNCActive(PWND Wnd)
Definition: nonclient.c:1398
#define DFCS_CAPTIONMAX
Definition: winuser.h:482
#define WVR_VREDRAW
Definition: winuser.h:2510
INT FASTCALL UserReleaseDC(PWND Window, HDC hDc, BOOL EndPaint)
Definition: windc.c:918
#define WNDS_NONCPAINT
Definition: ntuser.h:608
#define SM_CXVSCROLL
Definition: winuser.h:955
GLint dx
Definition: linetemp.h:97
#define DFC_SCROLL
Definition: winuser.h:475
struct _CURICON_OBJECT * PCURICON_OBJECT
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn UINT32 *TableIdx UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER void *Data ACPI_OBJECT_HANDLER void **Data ACPI_STRING ACPI_OBJECT_LIST ACPI_BUFFER *ReturnObjectBuffer ACPI_DEVICE_INFO **ReturnBuffer ACPI_HANDLE Parent
Definition: acpixf.h:732
#define HTVSCROLL
Definition: winuser.h:2472
BOOL WINAPI PtInRect(_In_ LPCRECT, _In_ POINT)
#define msg(x)
Definition: auth_time.c:54
#define RDW_UPDATENOW
Definition: winuser.h:1210
#define SC_MOVE
Definition: winuser.h:2575
#define SC_CLOSE
Definition: winuser.h:2582
#define HCBT_MOVESIZE
Definition: winuser.h:55
#define SM_CXSIZE
Definition: winuser.h:985
#define HASSIZEGRIP(Style, ExStyle, ParentStyle, WindowRect, ParentClientRect)
Definition: nonclient.c:34
FORCEINLINE BOOL RECTL_bIsEmptyRect(_In_ const RECTL *prcl)
Definition: rect.h:44
unsigned int ULONG
Definition: retypes.h:1
#define HAS_DLGFRAME(Style, ExStyle)
Definition: window.h:8
#define UserHasThickFrameStyle(Style, ExStyle)
Definition: nonclient.c:18
LONG bottom
Definition: windef.h:309
#define WNDS_FORCEMENUDRAW
Definition: ntuser.h:615
_In_ ULONG _In_ BOOLEAN Active
Definition: potypes.h:560
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
#define EDGE_SUNKEN
Definition: winuser.h:451
BOOL FASTCALL IntIsChildWindow(PWND Parent, PWND BaseWindow)
Definition: window.c:925
struct _WND::@4898 InternalPos
BOOL FASTCALL UserSystemParametersInfo(UINT uiAction, UINT uiParam, PVOID pvParam, UINT fWinIni)
Definition: sysparams.c:2090
BOOL FASTCALL co_IntSetForegroundWindowMouse(PWND Window)
Definition: focus.c:1561
#define PM_REMOVE
Definition: winuser.h:1186
#define MF_GRAYED
Definition: winuser.h:129
LRESULT NC_HandleNCLButtonDown(PWND pWnd, WPARAM wParam, LPARAM lParam)
Definition: nonclient.c:1553
#define HTCLIENT
Definition: winuser.h:2465
#define WNDS_HASMENU
Definition: ntuser.h:600
BOOL WINAPI ScreenToClient(_In_ HWND, _Inout_ LPPOINT)
DWORD FASTCALL GetNCHitEx(PWND pWnd, POINT pt)
Definition: nonclient.c:1963
LONG_PTR LRESULT
Definition: windef.h:209
PCURICON_OBJECT FASTCALL UserSetCursor(PCURICON_OBJECT NewCursor, BOOL ForceChange)
Definition: msgqueue.c:93
LRESULT NC_HandleNCActivate(PWND Wnd, WPARAM wParam, LPARAM lParam)
Definition: nonclient.c:1416
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
DBG_DEFAULT_CHANNEL(UserDefwnd)
Arabic default style
Definition: afstyles.h:93
#define WS_VISIBLE
Definition: pedump.c:620
#define WS_SYSMENU
Definition: pedump.c:629
#define DC_CAPTION
Definition: winuser.h:439
PUSER_HANDLE_TABLE gHandleTable
Definition: object.c:13
HMENU WINAPI GetMenu(_In_ HWND)
VOID NC_DoButton(PWND pWnd, WPARAM wParam, LPARAM lParam)
Definition: nonclient.c:1473
#define WM_SYSCOMMAND
Definition: winuser.h:1731
#define SM_CYSMCAPTION
Definition: winuser.h:1008
#define SC_VSCROLL
Definition: winuser.h:2583
LONG cy
Definition: windef.h:335
struct @1595 Msg[]
#define WS_EX_STATICEDGE
Definition: winuser.h:403
LPARAM lParam
Definition: combotst.c:139
#define DC_TEXT
Definition: winuser.h:430
#define WM_ENTERSIZEMOVE
Definition: winuser.h:1813
#define DFCS_CAPTIONMIN
Definition: winuser.h:481
#define WMSZ_LEFT
Definition: winuser.h:2454
#define WNDS_HASCAPTION
Definition: ntuser.h:603
struct Rect Rect
#define ON_LEFT_BORDER(hit)
Definition: nonclient.c:25
const DWORD ExStyle
Definition: appswitch.c:72
static UINT WPARAM wparam
Definition: combo.c:716
BOOL UserDrawCaption(PWND pWnd, HDC hDc, RECTL *lpRc, HFONT hFont, HICON hIcon, const PUNICODE_STRING Str, UINT uFlags)
Definition: painting.c:2197
UINT FASTCALL IntGetMenuState(HMENU hMenu, UINT uId, UINT uFlags)
Definition: menu.c:4975
VOID FASTCALL UserReferenceObject(PVOID obj)
Definition: object.c:731
PCLS pcls
Definition: ntuser.h:715
#define WS_MAXIMIZE
Definition: pedump.c:623
DWORD style
Definition: ntuser.h:701
BOOL FASTCALL IntGetWindowRect(PWND Wnd, RECTL *Rect)
Definition: winpos.c:120
#define SC_HSCROLL
Definition: winuser.h:2584