1 /*
2 * PROJECT: ReactOS Win32k subsystem
3 * LICENSE: See COPYING in the top level directory
4 * PURPOSE: Miscellaneous User functions
5 * COPYRIGHT: 2008-2020 James Tabor <james.tabor@reactos.org>
6 */
7
8 #include <win32k.h>
9 #include <windowsx.h>
10
11 DBG_DEFAULT_CHANNEL(UserDefwnd);
12
13 INT WINAPI DrawTextExWorker( HDC hdc, LPWSTR str, INT i_count,
14 LPRECT rect, UINT flags, LPDRAWTEXTPARAMS dtp );
15
DrawTextW(HDC hdc,LPCWSTR str,INT count,LPRECT rect,UINT flags)16 INT WINAPI DrawTextW( HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags )
17 {
18 DRAWTEXTPARAMS dtp;
19
20 memset (&dtp, 0, sizeof(dtp));
21 dtp.cbSize = sizeof(dtp);
22 if (flags & DT_TABSTOP)
23 {
24 dtp.iTabLength = (flags >> 8) & 0xff;
25 flags &= 0xffff00ff;
26 }
27 return DrawTextExWorker(hdc, (LPWSTR)str, count, rect, flags, &dtp);
28 }
29
30
31 HBRUSH FASTCALL
DefWndControlColor(HDC hDC,UINT ctlType)32 DefWndControlColor(HDC hDC, UINT ctlType)
33 {
34 if (ctlType == CTLCOLOR_SCROLLBAR)
35 {
36 HBRUSH hb = IntGetSysColorBrush(COLOR_SCROLLBAR);
37 COLORREF bk = IntGetSysColor(COLOR_3DHILIGHT);
38 IntGdiSetTextColor(hDC, IntGetSysColor(COLOR_3DFACE));
39 IntGdiSetBkColor(hDC, bk);
40
41 /* if COLOR_WINDOW happens to be the same as COLOR_3DHILIGHT
42 * we better use 0x55aa bitmap brush to make scrollbar's background
43 * look different from the window background.
44 */
45 if ( bk == IntGetSysColor(COLOR_WINDOW))
46 return gpsi->hbrGray;
47
48 NtGdiUnrealizeObject( hb );
49 return hb;
50 }
51
52 IntGdiSetTextColor(hDC, IntGetSysColor(COLOR_WINDOWTEXT));
53
54 if ((ctlType == CTLCOLOR_EDIT) || (ctlType == CTLCOLOR_LISTBOX))
55 {
56 IntGdiSetBkColor(hDC, IntGetSysColor(COLOR_WINDOW));
57 }
58 else
59 {
60 IntGdiSetBkColor(hDC, IntGetSysColor(COLOR_3DFACE));
61 return IntGetSysColorBrush(COLOR_3DFACE);
62 }
63
64 return IntGetSysColorBrush(COLOR_WINDOW);
65 }
66
67 LRESULT FASTCALL
DefWndHandleWindowPosChanging(PWND pWnd,WINDOWPOS * Pos)68 DefWndHandleWindowPosChanging(PWND pWnd, WINDOWPOS* Pos)
69 {
70 POINT maxTrack, minTrack;
71 LONG style = pWnd->style;
72
73 if (Pos->flags & SWP_NOSIZE) return 0;
74 if ((style & WS_THICKFRAME) || ((style & (WS_POPUP | WS_CHILD)) == 0))
75 {
76 co_WinPosGetMinMaxInfo(pWnd, NULL, NULL, &minTrack, &maxTrack);
77 Pos->cx = min(Pos->cx, maxTrack.x);
78 Pos->cy = min(Pos->cy, maxTrack.y);
79 if (!(style & WS_MINIMIZE))
80 {
81 if (Pos->cx < minTrack.x) Pos->cx = minTrack.x;
82 if (Pos->cy < minTrack.y) Pos->cy = minTrack.y;
83 }
84 }
85 else
86 {
87 Pos->cx = max(Pos->cx, 0);
88 Pos->cy = max(Pos->cy, 0);
89 }
90 return 0;
91 }
92
93 /* Win: xxxHandleWindowPosChanged */
94 LRESULT FASTCALL
DefWndHandleWindowPosChanged(PWND pWnd,WINDOWPOS * Pos)95 DefWndHandleWindowPosChanged(PWND pWnd, WINDOWPOS* Pos)
96 {
97 RECT Rect;
98 LONG style = pWnd->style;
99
100 IntGetClientRect(pWnd, &Rect);
101 IntMapWindowPoints(pWnd, (style & WS_CHILD ? IntGetParent(pWnd) : NULL), (LPPOINT) &Rect, 2);
102
103 if (!(Pos->flags & SWP_NOCLIENTMOVE))
104 {
105 co_IntSendMessage(UserHMGetHandle(pWnd), WM_MOVE, 0, MAKELONG(Rect.left, Rect.top));
106 }
107
108 if (!(Pos->flags & SWP_NOCLIENTSIZE) || (Pos->flags & SWP_STATECHANGED))
109 {
110 if (style & WS_MINIMIZE) co_IntSendMessage(UserHMGetHandle(pWnd), WM_SIZE, SIZE_MINIMIZED, 0 );
111 else
112 {
113 WPARAM wp = (style & WS_MAXIMIZE) ? SIZE_MAXIMIZED : SIZE_RESTORED;
114 co_IntSendMessage(UserHMGetHandle(pWnd), WM_SIZE, wp, MAKELONG(Rect.right - Rect.left, Rect.bottom - Rect.top));
115 }
116 }
117 return 0;
118 }
119
120 //
121 // Handle a WM_SYSCOMMAND message. Called from DefWindowProc().
122 //
123 // Win: xxxSysCommand
124 LRESULT FASTCALL
DefWndHandleSysCommand(PWND pWnd,WPARAM wParam,LPARAM lParam)125 DefWndHandleSysCommand(PWND pWnd, WPARAM wParam, LPARAM lParam)
126 {
127 LRESULT lResult = 0;
128 BOOL Hook = FALSE;
129
130 if (ISITHOOKED(WH_CBT) || (pWnd->head.rpdesk->pDeskInfo->fsHooks & HOOKID_TO_FLAG(WH_CBT)))
131 {
132 Hook = TRUE;
133 lResult = co_HOOK_CallHooks(WH_CBT, HCBT_SYSCOMMAND, wParam, lParam);
134
135 if (lResult) return lResult;
136 }
137
138 switch (wParam & 0xfff0)
139 {
140 case SC_MOVE:
141 case SC_SIZE:
142 DefWndDoSizeMove(pWnd, wParam);
143 break;
144
145 case SC_MINIMIZE:
146 if (UserHMGetHandle(pWnd) == UserGetActiveWindow())
147 IntShowOwnedPopups(pWnd,FALSE); // This is done in ShowWindow! Need to retest!
148 co_WinPosShowWindow( pWnd, SW_MINIMIZE );
149 break;
150
151 case SC_MAXIMIZE:
152 if (((pWnd->style & WS_MINIMIZE) != 0) && UserHMGetHandle(pWnd) == UserGetActiveWindow())
153 IntShowOwnedPopups(pWnd,TRUE);
154 co_WinPosShowWindow( pWnd, SW_MAXIMIZE );
155 break;
156
157 case SC_RESTORE:
158 if (((pWnd->style & WS_MINIMIZE) != 0) && UserHMGetHandle(pWnd) == UserGetActiveWindow())
159 IntShowOwnedPopups(pWnd,TRUE);
160 co_WinPosShowWindow( pWnd, SW_RESTORE );
161 break;
162
163 case SC_CLOSE:
164 return co_IntSendMessage(UserHMGetHandle(pWnd), WM_CLOSE, 0, 0);
165
166 case SC_SCREENSAVE:
167 ERR("Screensaver Called!\n");
168 UserPostMessage(hwndSAS, WM_LOGONNOTIFY, LN_START_SCREENSAVE, 0); // always lParam 0 == not Secure
169 break;
170
171 case SC_HOTKEY:
172 {
173 USER_REFERENCE_ENTRY Ref;
174
175 pWnd = ValidateHwndNoErr((HWND)lParam);
176 if (pWnd)
177 {
178 if (pWnd->spwndLastActive)
179 {
180 pWnd = pWnd->spwndLastActive;
181 }
182 UserRefObjectCo(pWnd, &Ref);
183 co_IntSetForegroundWindow(pWnd);
184 UserDerefObjectCo(pWnd);
185 if (pWnd->style & WS_MINIMIZE)
186 {
187 UserPostMessage(UserHMGetHandle(pWnd), WM_SYSCOMMAND, SC_RESTORE, 0);
188 }
189 }
190 }
191 break;
192
193 // case SC_DEFAULT:
194 case SC_MOUSEMENU:
195 {
196 POINT Pt;
197 Pt.x = (short)LOWORD(lParam);
198 Pt.y = (short)HIWORD(lParam);
199 MENU_TrackMouseMenuBar(pWnd, wParam & 0x000f, Pt);
200 }
201 break;
202
203 case SC_KEYMENU:
204 MENU_TrackKbdMenuBar(pWnd, wParam, (WCHAR)lParam);
205 break;
206
207 default:
208 // We do not support anything else here so we should return normal even when sending a hook.
209 return 0;
210 }
211
212 return(Hook ? 1 : 0); // Don't call us again from user space.
213 }
214
215 PWND FASTCALL
co_IntFindChildWindowToOwner(PWND Root,PWND Owner)216 co_IntFindChildWindowToOwner(PWND Root, PWND Owner)
217 {
218 PWND Ret;
219 PWND Child, OwnerWnd;
220
221 for(Child = Root->spwndChild; Child; Child = Child->spwndNext)
222 {
223 OwnerWnd = Child->spwndOwner;
224 if(!OwnerWnd)
225 continue;
226
227 if (!(Child->style & WS_POPUP) ||
228 !(Child->style & WS_VISIBLE) ||
229 /* Fixes CMD pop up properties window from having foreground. */
230 Owner->head.pti->MessageQueue != Child->head.pti->MessageQueue)
231 continue;
232
233 if(OwnerWnd == Owner)
234 {
235 Ret = Child;
236 return Ret;
237 }
238 }
239 return NULL;
240 }
241
242 LRESULT
DefWndHandleSetCursor(PWND pWnd,WPARAM wParam,LPARAM lParam)243 DefWndHandleSetCursor(PWND pWnd, WPARAM wParam, LPARAM lParam)
244 {
245 PWND pwndPopUP = NULL;
246 WORD Msg = HIWORD(lParam);
247
248 /* Not for child windows. */
249 if (UserHMGetHandle(pWnd) != (HWND)wParam)
250 {
251 return FALSE;
252 }
253
254 switch((short)LOWORD(lParam))
255 {
256 case HTERROR:
257 {
258 //// This is the real fix for CORE-6129! This was a "Code hole".
259 USER_REFERENCE_ENTRY Ref;
260
261 if (Msg == WM_LBUTTONDOWN)
262 {
263 // Find a pop up window to bring active.
264 pwndPopUP = co_IntFindChildWindowToOwner(UserGetDesktopWindow(), pWnd);
265 if (pwndPopUP)
266 {
267 // Not a child pop up from desktop.
268 if ( pwndPopUP != UserGetDesktopWindow()->spwndChild )
269 {
270 // Get original active window.
271 PWND pwndOrigActive = gpqForeground->spwndActive;
272
273 co_WinPosSetWindowPos(pWnd, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
274
275 UserRefObjectCo(pwndPopUP, &Ref);
276 //UserSetActiveWindow(pwndPopUP);
277 co_IntSetForegroundWindow(pwndPopUP); // HACK
278 UserDerefObjectCo(pwndPopUP);
279
280 // If the change was made, break out.
281 if (pwndOrigActive != gpqForeground->spwndActive)
282 break;
283 }
284 }
285 }
286 ////
287 if (Msg == WM_LBUTTONDOWN || Msg == WM_MBUTTONDOWN ||
288 Msg == WM_RBUTTONDOWN || Msg == WM_XBUTTONDOWN)
289 {
290 if (pwndPopUP)
291 {
292 FLASHWINFO fwi =
293 {sizeof(FLASHWINFO),
294 UserHMGetHandle(pwndPopUP),
295 FLASHW_ALL,
296 gspv.dwForegroundFlashCount,
297 (gpsi->dtCaretBlink >> 3)};
298
299 // Now shake that window!
300 IntFlashWindowEx(pwndPopUP, &fwi);
301 }
302 UserPostMessage(hwndSAS, WM_LOGONNOTIFY, LN_MESSAGE_BEEP, 0);
303 }
304 break;
305 }
306
307 case HTCLIENT:
308 {
309 if (pWnd->pcls->spcur)
310 {
311 IntSystemSetCursor(pWnd->pcls->spcur);
312 }
313 return FALSE;
314 }
315
316 case HTLEFT:
317 case HTRIGHT:
318 {
319 if (pWnd->style & WS_MAXIMIZE)
320 {
321 break;
322 }
323 IntSystemSetCursor(SYSTEMCUR(SIZEWE));
324 return TRUE;
325 }
326
327 case HTTOP:
328 case HTBOTTOM:
329 {
330 if (pWnd->style & WS_MAXIMIZE)
331 {
332 break;
333 }
334 IntSystemSetCursor(SYSTEMCUR(SIZENS));
335 return TRUE;
336 }
337
338 case HTTOPLEFT:
339 case HTBOTTOMRIGHT:
340 {
341 if (pWnd->style & WS_MAXIMIZE)
342 {
343 break;
344 }
345 IntSystemSetCursor(SYSTEMCUR(SIZENWSE));
346 return TRUE;
347 }
348
349 case HTBOTTOMLEFT:
350 case HTTOPRIGHT:
351 {
352 if (pWnd->style & WS_MAXIMIZE)
353 {
354 break;
355 }
356 IntSystemSetCursor(SYSTEMCUR(SIZENESW));
357 return TRUE;
358 }
359 }
360 IntSystemSetCursor(SYSTEMCUR(ARROW));
361 return FALSE;
362 }
363
364 /* Win: xxxDWPPrint */
DefWndPrint(PWND pwnd,HDC hdc,ULONG uFlags)365 VOID FASTCALL DefWndPrint( PWND pwnd, HDC hdc, ULONG uFlags)
366 {
367 /*
368 * Visibility flag.
369 */
370 if ( (uFlags & PRF_CHECKVISIBLE) &&
371 !IntIsWindowVisible(pwnd) )
372 return;
373
374 /*
375 * Unimplemented flags.
376 */
377 if ( (uFlags & PRF_CHILDREN) ||
378 (uFlags & PRF_OWNED) ||
379 (uFlags & PRF_NONCLIENT) )
380 {
381 FIXME("WM_PRINT message with unsupported flags\n");
382 }
383
384 /*
385 * Background
386 */
387 if ( uFlags & PRF_ERASEBKGND)
388 co_IntSendMessage(UserHMGetHandle(pwnd), WM_ERASEBKGND, (WPARAM)hdc, 0);
389
390 /*
391 * Client area
392 */
393 if ( uFlags & PRF_CLIENT)
394 co_IntSendMessage(UserHMGetHandle(pwnd), WM_PRINTCLIENT, (WPARAM)hdc, uFlags);
395 }
396
397 BOOL
UserPaintCaption(PWND pWnd,INT Flags)398 UserPaintCaption(PWND pWnd, INT Flags)
399 {
400 BOOL Ret = FALSE;
401
402 if ( (pWnd->style & WS_VISIBLE) && ((pWnd->style & WS_CAPTION) == WS_CAPTION) )
403 {
404 if (pWnd->state & WNDS_HASCAPTION && pWnd->head.pti->MessageQueue == gpqForeground)
405 Flags |= DC_ACTIVE;
406 /*
407 * When themes are not enabled we can go on and paint the non client area.
408 * However if we do that with themes enabled we will draw a classic frame.
409 * This is solved by sending a themes specific message to notify the themes
410 * engine that the caption needs to be redrawn.
411 */
412 if (gpsi->dwSRVIFlags & SRVINFO_APIHOOK)
413 {
414 /*
415 * This will cause uxtheme to either paint the themed caption or call
416 * RealUserDrawCaption in order to draw the classic caption when themes
417 * are disabled but the themes service is enabled.
418 */
419 TRACE("UDCB Flags %08x\n", Flags);
420 co_IntSendMessage(UserHMGetHandle(pWnd), WM_NCUAHDRAWCAPTION, Flags, 0);
421 }
422 else
423 {
424 HDC hDC = UserGetDCEx(pWnd, NULL, DCX_WINDOW|DCX_USESTYLE);
425 UserDrawCaptionBar(pWnd, hDC, Flags | DC_FRAME); // DCFRAME added as fix for CORE-10855.
426 UserReleaseDC(pWnd, hDC, FALSE);
427 }
428 Ret = TRUE;
429 }
430 // Support window tray
431 return Ret;
432 }
433
434 // WM_SETICON
435 /* Win: xxxDWP_SetIcon */
436 LRESULT FASTCALL
DefWndSetIcon(PWND pWnd,WPARAM wParam,LPARAM lParam)437 DefWndSetIcon(PWND pWnd, WPARAM wParam, LPARAM lParam)
438 {
439 HICON hIcon, hIconSmall, hIconOld;
440
441 if ( wParam > ICON_SMALL2 )
442 {
443 EngSetLastError(ERROR_INVALID_PARAMETER);
444 return 0;
445 }
446 hIconSmall = UserGetProp(pWnd, gpsi->atomIconSmProp, TRUE);
447 hIcon = UserGetProp(pWnd, gpsi->atomIconProp, TRUE);
448
449 hIconOld = wParam == ICON_BIG ? hIcon : hIconSmall;
450
451 switch(wParam)
452 {
453 case ICON_BIG:
454 hIcon = (HICON)lParam;
455 break;
456 case ICON_SMALL:
457 hIconSmall = (HICON)lParam;
458 break;
459 case ICON_SMALL2:
460 ERR("FIXME: Set ICON_SMALL2 support!\n");
461 default:
462 break;
463 }
464
465 UserSetProp(pWnd, gpsi->atomIconProp, hIcon, TRUE);
466 UserSetProp(pWnd, gpsi->atomIconSmProp, hIconSmall, TRUE);
467
468 if ((pWnd->style & WS_CAPTION ) == WS_CAPTION)
469 UserPaintCaption(pWnd, DC_ICON);
470
471 return (LRESULT)hIconOld;
472 }
473
474 /* Win: DWP_GetIcon */
475 LRESULT FASTCALL
DefWndGetIcon(PWND pWnd,WPARAM wParam,LPARAM lParam)476 DefWndGetIcon(PWND pWnd, WPARAM wParam, LPARAM lParam)
477 {
478 HICON hIconRet;
479 if ( wParam > ICON_SMALL2 )
480 {
481 EngSetLastError(ERROR_INVALID_PARAMETER);
482 return 0;
483 }
484 switch(wParam)
485 {
486 case ICON_BIG:
487 hIconRet = UserGetProp(pWnd, gpsi->atomIconProp, TRUE);
488 break;
489 case ICON_SMALL:
490 case ICON_SMALL2:
491 hIconRet = UserGetProp(pWnd, gpsi->atomIconSmProp, TRUE);
492 break;
493 DEFAULT_UNREACHABLE;
494 }
495 return (LRESULT)hIconRet;
496 }
497
498 VOID FASTCALL
DefWndScreenshot(PWND pWnd)499 DefWndScreenshot(PWND pWnd)
500 {
501 RECT rect;
502 HDC hdc;
503 INT w;
504 INT h;
505 HBITMAP hbitmap;
506 HDC hdc2;
507 SETCLIPBDATA scd = {FALSE, FALSE};
508
509 UserOpenClipboard(UserHMGetHandle(pWnd));
510 UserEmptyClipboard();
511
512 hdc = UserGetWindowDC(pWnd);
513 IntGetWindowRect(pWnd, &rect);
514 w = rect.right - rect.left;
515 h = rect.bottom - rect.top;
516
517 hbitmap = NtGdiCreateCompatibleBitmap(hdc, w, h);
518 hdc2 = NtGdiCreateCompatibleDC(hdc);
519 NtGdiSelectBitmap(hdc2, hbitmap);
520
521 NtGdiBitBlt(hdc2, 0, 0, w, h, hdc, 0, 0, SRCCOPY, 0, 0);
522
523 UserSetClipboardData(CF_BITMAP, hbitmap, &scd);
524
525 UserReleaseDC(pWnd, hdc, FALSE);
526 UserReleaseDC(pWnd, hdc2, FALSE);
527
528 UserCloseClipboard();
529 }
530
531 /*
532 Win32k counterpart of User DefWindowProc
533 */
534 LRESULT FASTCALL
IntDefWindowProc(PWND Wnd,UINT Msg,WPARAM wParam,LPARAM lParam,BOOL Ansi)535 IntDefWindowProc(
536 PWND Wnd,
537 UINT Msg,
538 WPARAM wParam,
539 LPARAM lParam,
540 BOOL Ansi)
541 {
542 PTHREADINFO pti = PsGetCurrentThreadWin32Thread();
543 LRESULT lResult = 0;
544 USER_REFERENCE_ENTRY Ref;
545
546 if (Msg > WM_USER) return 0;
547
548 switch (Msg)
549 {
550 case WM_DEVICECHANGE:
551 return TRUE;
552
553 case WM_GETTEXTLENGTH:
554 {
555 PWSTR buf;
556 ULONG len;
557
558 if (Wnd != NULL && Wnd->strName.Length != 0)
559 {
560 buf = Wnd->strName.Buffer;
561 if (buf != NULL &&
562 NT_SUCCESS(RtlUnicodeToMultiByteSize(&len,
563 buf,
564 Wnd->strName.Length)))
565 {
566 lResult = (LRESULT) (Wnd->strName.Length / sizeof(WCHAR));
567 }
568 }
569
570 break;
571 }
572
573 case WM_GETTEXT: // FIXME: Handle Ansi
574 {
575 PWSTR buf = NULL;
576 PWSTR outbuf = (PWSTR)lParam;
577
578 if (Wnd != NULL && wParam != 0)
579 {
580 if (Wnd->strName.Buffer != NULL)
581 buf = Wnd->strName.Buffer;
582 else
583 outbuf[0] = L'\0';
584
585 if (buf != NULL)
586 {
587 if (Wnd->strName.Length != 0)
588 {
589 lResult = min(Wnd->strName.Length / sizeof(WCHAR), wParam - 1);
590 RtlCopyMemory(outbuf,
591 buf,
592 lResult * sizeof(WCHAR));
593 outbuf[lResult] = L'\0';
594 }
595 else
596 outbuf[0] = L'\0';
597 }
598 }
599 break;
600 }
601
602 case WM_SETTEXT: // FIXME: Handle Ansi
603 {
604 DefSetText(Wnd, (PCWSTR)lParam);
605
606 if ((Wnd->style & WS_CAPTION) == WS_CAPTION)
607 UserPaintCaption(Wnd, DC_TEXT);
608 IntNotifyWinEvent(EVENT_OBJECT_NAMECHANGE, Wnd, OBJID_WINDOW, CHILDID_SELF, 0);
609 lResult = 1;
610 break;
611 }
612
613 case WM_SYSCOMMAND:
614 {
615 TRACE("hwnd %p WM_SYSCOMMAND %lx %lx\n", UserHMGetHandle(Wnd), wParam, lParam );
616 lResult = DefWndHandleSysCommand(Wnd, wParam, lParam);
617 break;
618 }
619
620 case WM_SHOWWINDOW:
621 {
622 if ((Wnd->style & WS_VISIBLE) && wParam) break;
623 if (!(Wnd->style & WS_VISIBLE) && !wParam) break;
624 if (!Wnd->spwndOwner) break;
625 if (LOWORD(lParam))
626 {
627 co_WinPosShowWindow(Wnd, wParam ? SW_SHOWNOACTIVATE : SW_HIDE);
628 }
629 break;
630 }
631
632 case WM_CLIENTSHUTDOWN:
633 return IntClientShutdown(Wnd, wParam, lParam);
634
635 case WM_APPCOMMAND:
636 if ( (Wnd->style & (WS_POPUP|WS_CHILD)) != WS_CHILD &&
637 Wnd != co_GetDesktopWindow(Wnd) )
638 {
639 if (!co_HOOK_CallHooks(WH_SHELL, HSHELL_APPCOMMAND, wParam, lParam))
640 co_IntShellHookNotify(HSHELL_APPCOMMAND, wParam, lParam);
641 break;
642 }
643 UserRefObjectCo(Wnd->spwndParent, &Ref);
644 lResult = co_IntSendMessage(UserHMGetHandle(Wnd->spwndParent), WM_APPCOMMAND, wParam, lParam);
645 UserDerefObjectCo(Wnd->spwndParent);
646 break;
647
648 case WM_KEYF1:
649 {
650 HELPINFO hi;
651 HMENU hMenu = UlongToHandle(Wnd->IDMenu);
652 PWND pwndActive = MENU_IsMenuActive();
653 hi.cbSize = sizeof(HELPINFO);
654 hi.MousePos = gpsi->ptCursor;
655 hi.iContextType = HELPINFO_MENUITEM;
656 hi.hItemHandle = pwndActive ? UserHMGetHandle(pwndActive) : UserHMGetHandle(Wnd);
657 hi.iCtrlId = (Wnd->style & (WS_POPUP|WS_CHILD)) == WS_CHILD ? IntMenuItemFromPoint(Wnd, hMenu, hi.MousePos) : 0;
658 hi.dwContextId = IntGetWindowContextHelpId(Wnd);
659
660 co_IntSendMessage( UserHMGetHandle(Wnd), WM_HELP, 0, (LPARAM)&hi );
661 break;
662 }
663
664 case WM_SETICON:
665 {
666 return DefWndSetIcon(Wnd, wParam, lParam);
667 }
668
669 case WM_GETICON:
670 {
671 return DefWndGetIcon(Wnd, wParam, lParam);
672 }
673
674 case WM_HELP:
675 {
676 PWND Parent = IntGetParent(Wnd);
677 co_IntSendMessage(UserHMGetHandle(Parent), Msg, wParam, lParam);
678 break;
679 }
680
681 case WM_LBUTTONDOWN:
682 case WM_RBUTTONDOWN:
683 case WM_MBUTTONDOWN:
684 pti->MessageQueue->QF_flags &= ~(QF_FMENUSTATUS|QF_FMENUSTATUSBREAK);
685 break;
686
687 case WM_NCLBUTTONDOWN:
688 return NC_HandleNCLButtonDown(Wnd, wParam, lParam);
689
690 case WM_NCRBUTTONDOWN:
691 return NC_HandleNCRButtonDown(Wnd, wParam, lParam);
692
693 case WM_LBUTTONDBLCLK:
694 return NC_HandleNCLButtonDblClk(Wnd, HTCLIENT, lParam);
695
696 case WM_NCLBUTTONDBLCLK:
697 return NC_HandleNCLButtonDblClk(Wnd, wParam, lParam);
698
699 case WM_RBUTTONUP:
700 {
701 POINT Pt;
702
703 Pt.x = GET_X_LPARAM(lParam);
704 Pt.y = GET_Y_LPARAM(lParam);
705 IntClientToScreen(Wnd, &Pt);
706 lParam = MAKELPARAM(Pt.x, Pt.y);
707 co_IntSendMessage(UserHMGetHandle(Wnd), WM_CONTEXTMENU, (WPARAM)UserHMGetHandle(Wnd), lParam);
708 break;
709 }
710
711 case WM_NCRBUTTONUP:
712 /*
713 * FIXME : we must NOT send WM_CONTEXTMENU on a WM_NCRBUTTONUP (checked
714 * in Windows), but what _should_ we do? According to MSDN :
715 * "If it is appropriate to do so, the system sends the WM_SYSCOMMAND
716 * message to the window". When is it appropriate?
717 */
718 ERR("WM_NCRBUTTONUP\n");
719 break;
720
721 case WM_XBUTTONUP:
722 case WM_NCXBUTTONUP:
723 if (HIWORD(wParam) == XBUTTON1 || HIWORD(wParam) == XBUTTON2)
724 {
725 co_IntSendMessage(UserHMGetHandle(Wnd), WM_APPCOMMAND, (WPARAM)UserHMGetHandle(Wnd),
726 MAKELPARAM(LOWORD(wParam), FAPPCOMMAND_MOUSE | HIWORD(wParam)));
727 }
728 break;
729
730
731 case WM_CONTEXTMENU:
732 {
733 if (Wnd->style & WS_CHILD)
734 {
735 co_IntSendMessage(UserHMGetHandle(IntGetParent(Wnd)), Msg, (WPARAM)UserHMGetHandle(Wnd), lParam);
736 }
737 else
738 {
739 POINT Pt;
740 LONG_PTR Style;
741 LONG HitCode;
742
743 Style = Wnd->style;
744
745 Pt.x = GET_X_LPARAM(lParam);
746 Pt.y = GET_Y_LPARAM(lParam);
747 if (Style & WS_CHILD)
748 {
749 IntScreenToClient(IntGetParent(Wnd), &Pt);
750 }
751
752 HitCode = GetNCHitEx(Wnd, Pt);
753
754 if (HitCode == HTCAPTION || HitCode == HTSYSMENU)
755 {
756 PMENU SystemMenu;
757 UINT Flags;
758
759 if((SystemMenu = IntGetSystemMenu(Wnd, FALSE)))
760 {
761 MENU_InitSysMenuPopup(SystemMenu, Wnd->style, Wnd->pcls->style, HitCode);
762
763 if(HitCode == HTCAPTION)
764 Flags = TPM_LEFTBUTTON | TPM_RIGHTBUTTON;
765 else
766 Flags = TPM_LEFTBUTTON;
767
768 IntTrackPopupMenuEx(SystemMenu, Flags|TPM_SYSTEM_MENU, Pt.x, Pt.y, Wnd, NULL);
769 }
770 }
771 if (HitCode == HTHSCROLL || HitCode == HTVSCROLL)
772 {
773 WARN("Scroll Menu Not Supported\n");
774 }
775 }
776 break;
777 }
778
779 case WM_KEYDOWN:
780 if (wParam == VK_F10)
781 {
782 pti->MessageQueue->QF_flags |= QF_FF10STATUS;
783
784 if (UserGetKeyState(VK_SHIFT) & 0x8000)
785 {
786 co_IntSendMessage(UserHMGetHandle(Wnd), WM_CONTEXTMENU, (WPARAM)UserHMGetHandle(Wnd), MAKELPARAM(-1, -1));
787 }
788 }
789 if (g_bWindowSnapEnabled && (IS_KEY_DOWN(gafAsyncKeyState, VK_LWIN) || IS_KEY_DOWN(gafAsyncKeyState, VK_RWIN)))
790 {
791 HWND hwndTop = UserGetForegroundWindow();
792 PWND topWnd = UserGetWindowObject(hwndTop);
793 BOOL allowSnap;
794
795 // MS Doc: foreground window can be NULL, e.g. when window is losing activation
796 if (!topWnd)
797 return 0;
798
799 allowSnap = IntIsSnapAllowedForWindow(topWnd);
800 /* Allow the minimize action if it has a minimize button, even if the window cannot be snapped (e.g. Calc.exe) */
801 if (!allowSnap && (topWnd->style & (WS_MINIMIZEBOX|WS_THICKFRAME)) == WS_MINIMIZEBOX)
802 allowSnap = wParam == VK_DOWN;
803
804 if (allowSnap)
805 {
806 UINT snapped = IntGetWindowSnapEdge(topWnd);
807
808 if (wParam == VK_DOWN)
809 {
810 if (topWnd->style & WS_MAXIMIZE)
811 co_IntSendMessage(hwndTop, WM_SYSCOMMAND, SC_RESTORE, MAKELONG(0, 1));
812 else if (snapped)
813 co_IntUnsnapWindow(topWnd);
814 else
815 co_IntSendMessage(hwndTop, WM_SYSCOMMAND, SC_MINIMIZE, MAKELONG(0, 1));
816 }
817 else if (wParam == VK_UP)
818 {
819 if (topWnd->style & WS_MINIMIZE)
820 co_IntSendMessage(hwndTop, WM_SYSCOMMAND, SC_RESTORE, MAKELONG(0, 1));
821 else
822 co_IntSendMessage(hwndTop, WM_SYSCOMMAND, SC_MAXIMIZE, MAKELONG(0, 1));
823 }
824 else if (wParam == VK_LEFT || wParam == VK_RIGHT)
825 {
826 UINT edge = wParam == VK_LEFT ? HTLEFT : HTRIGHT;
827 UINT otherEdge = edge == HTLEFT ? HTRIGHT : HTLEFT;
828
829 if (topWnd->style & WS_MAXIMIZE)
830 {
831 /* SC_RESTORE + Snap causes the window to visually move twice, place it manually in the snap position */
832 RECT normalRect = topWnd->InternalPos.NormalRect;
833 co_IntCalculateSnapPosition(topWnd, edge, &topWnd->InternalPos.NormalRect); /* Calculate edge position */
834 IntSetSnapEdge(topWnd, edge); /* Tell everyone the edge we are snapped to */
835 co_IntSendMessage(hwndTop, WM_SYSCOMMAND, SC_RESTORE, MAKELONG(0, 1));
836 IntSetSnapInfo(topWnd, edge, &normalRect); /* Reset the real place to unsnap to */
837 snapped = HTNOWHERE; /* Force snap */
838 }
839 #if 0 /* Windows 8 does this but is it a good feature? */
840 else if (snapped == edge)
841 {
842 /* Already snapped to this edge, snap to the opposite side */
843 edge = otherEdge;
844 }
845 #endif
846
847 if (snapped == otherEdge)
848 co_IntUnsnapWindow(topWnd);
849 else
850 co_IntSnapWindow(topWnd, edge);
851 }
852 }
853 }
854 break;
855
856 case WM_SYSKEYDOWN:
857 {
858 if (HIWORD(lParam) & KF_ALTDOWN)
859 { /* Previous state, if the key was down before this message,
860 this is a cheap way to ignore autorepeat keys. */
861 if ( !(HIWORD(lParam) & KF_REPEAT) )
862 {
863 if ( ( wParam == VK_MENU ||
864 wParam == VK_LMENU ||
865 wParam == VK_RMENU ) && !(pti->MessageQueue->QF_flags & QF_FMENUSTATUS)) //iMenuSysKey )
866 pti->MessageQueue->QF_flags |= QF_FMENUSTATUS; //iMenuSysKey = 1;
867 else
868 pti->MessageQueue->QF_flags &= ~QF_FMENUSTATUS; //iMenuSysKey = 0;
869 }
870
871 pti->MessageQueue->QF_flags &= ~QF_FF10STATUS; //iF10Key = 0;
872
873 if (wParam == VK_F4) /* Try to close the window */
874 {
875 PWND top = UserGetAncestor(Wnd, GA_ROOT);
876 if (!(top->pcls->style & CS_NOCLOSE))
877 UserPostMessage(UserHMGetHandle(top), WM_SYSCOMMAND, SC_CLOSE, 0);
878 }
879 else if (wParam == VK_SNAPSHOT) // Alt-VK_SNAPSHOT?
880 {
881 PWND pwnd = Wnd;
882 while (IntGetParent(pwnd) != NULL)
883 {
884 pwnd = IntGetParent(pwnd);
885 }
886 ERR("DefWndScreenshot\n");
887 DefWndScreenshot(pwnd);
888 }
889 else if ( wParam == VK_ESCAPE || wParam == VK_TAB ) // Alt-Tab/ESC Alt-Shift-Tab/ESC
890 {
891 WPARAM wParamTmp;
892 HWND Active = UserGetActiveWindow(); // Noticed MDI problem.
893 if (!Active)
894 {
895 FIXME("WM_SYSKEYDOWN VK_ESCAPE no active\n");
896 break;
897 }
898 wParamTmp = UserGetKeyState(VK_SHIFT) & 0x8000 ? SC_PREVWINDOW : SC_NEXTWINDOW;
899 co_IntSendMessage( Active, WM_SYSCOMMAND, wParamTmp, wParam );
900 }
901 }
902 else if( wParam == VK_F10 )
903 {
904 if (UserGetKeyState(VK_SHIFT) & 0x8000)
905 co_IntSendMessage( UserHMGetHandle(Wnd), WM_CONTEXTMENU, (WPARAM)UserHMGetHandle(Wnd), MAKELPARAM(-1, -1) );
906 pti->MessageQueue->QF_flags |= QF_FF10STATUS; //iF10Key = 1;
907 }
908 else if( wParam == VK_ESCAPE && (UserGetKeyState(VK_SHIFT) & 0x8000))
909 co_IntSendMessage( UserHMGetHandle(Wnd), WM_SYSCOMMAND, SC_KEYMENU, ' ' );
910 break;
911 }
912
913 case WM_KEYUP:
914 case WM_SYSKEYUP:
915 {
916 /* Press and release F10 or ALT */
917 if (((wParam == VK_MENU || wParam == VK_LMENU || wParam == VK_RMENU)
918 && (pti->MessageQueue->QF_flags & (QF_FMENUSTATUS|QF_FMENUSTATUSBREAK)) == QF_FMENUSTATUS /*iMenuSysKey*/) ||
919 ((wParam == VK_F10) && pti->MessageQueue->QF_flags & QF_FF10STATUS /*iF10Key*/))
920 co_IntSendMessage( UserHMGetHandle(UserGetAncestor( Wnd, GA_ROOT )), WM_SYSCOMMAND, SC_KEYMENU, 0L );
921 pti->MessageQueue->QF_flags &= ~(QF_FMENUSTATUS|QF_FMENUSTATUSBREAK|QF_FF10STATUS); //iMenuSysKey = iF10Key = 0;
922 break;
923 }
924
925 case WM_SYSCHAR:
926 {
927 pti->MessageQueue->QF_flags &= ~(QF_FMENUSTATUS|QF_FMENUSTATUSBREAK); //iMenuSysKey = 0;
928 if (wParam == VK_RETURN && (Wnd->style & WS_MINIMIZE) != 0)
929 {
930 UserPostMessage( UserHMGetHandle(Wnd), WM_SYSCOMMAND, SC_RESTORE, 0L );
931 break;
932 }
933 if ((HIWORD(lParam) & KF_ALTDOWN) && wParam)
934 {
935 if (wParam == VK_TAB || wParam == VK_ESCAPE) break;
936 if (wParam == VK_SPACE && Wnd->style & WS_CHILD)
937 co_IntSendMessage( UserHMGetHandle(IntGetParent(Wnd)), Msg, wParam, lParam );
938 else
939 co_IntSendMessage( UserHMGetHandle(Wnd), WM_SYSCOMMAND, SC_KEYMENU, wParam );
940 }
941 else /* check for Ctrl-Esc */
942 if (wParam != VK_ESCAPE) UserPostMessage(hwndSAS, WM_LOGONNOTIFY, LN_MESSAGE_BEEP, 0); //MessageBeep(0);
943 break;
944 }
945
946 case WM_CANCELMODE:
947 {
948 pti->MessageQueue->QF_flags &= ~(QF_FMENUSTATUS|QF_FMENUSTATUSBREAK);
949
950 MENU_EndMenu( Wnd );
951 if (IntGetCaptureWindow() == UserHMGetHandle(Wnd))
952 {
953 IntReleaseCapture();
954 }
955 break;
956 }
957
958 case WM_CLOSE:
959 co_UserDestroyWindow(Wnd);
960 break;
961
962 case WM_CTLCOLORMSGBOX:
963 case WM_CTLCOLOREDIT:
964 case WM_CTLCOLORLISTBOX:
965 case WM_CTLCOLORBTN:
966 case WM_CTLCOLORDLG:
967 case WM_CTLCOLORSTATIC:
968 case WM_CTLCOLORSCROLLBAR:
969 return (LRESULT) DefWndControlColor((HDC)wParam, Msg - WM_CTLCOLORMSGBOX);
970
971 case WM_CTLCOLOR:
972 return (LRESULT) DefWndControlColor((HDC)wParam, HIWORD(lParam));
973
974 case WM_SETCURSOR:
975 {
976 if (Wnd->style & WS_CHILD)
977 {
978 /* with the exception of the border around a resizable wnd,
979 * give the parent first chance to set the cursor */
980 if (LOWORD(lParam) < HTLEFT || LOWORD(lParam) > HTBOTTOMRIGHT)
981 {
982 PWND parent = Wnd->spwndParent;//IntGetParent( Wnd );
983 if (parent != UserGetDesktopWindow() &&
984 co_IntSendMessage( UserHMGetHandle(parent), WM_SETCURSOR, wParam, lParam))
985 return TRUE;
986 }
987 }
988 return DefWndHandleSetCursor(Wnd, wParam, lParam);
989 }
990
991 case WM_MOUSEACTIVATE:
992 if (Wnd->style & WS_CHILD)
993 {
994 HWND hwndParent;
995 PWND pwndParent = IntGetParent(Wnd);
996 hwndParent = pwndParent ? UserHMGetHandle(pwndParent) : NULL;
997 if (hwndParent)
998 {
999 lResult = co_IntSendMessage(hwndParent, WM_MOUSEACTIVATE, wParam, lParam);
1000 if (lResult)
1001 break;
1002 }
1003 }
1004 return ( (HIWORD(lParam) == WM_LBUTTONDOWN && LOWORD(lParam) == HTCAPTION) ? MA_NOACTIVATE : MA_ACTIVATE );
1005
1006 case WM_ACTIVATE:
1007 /* The default action in Windows is to set the keyboard focus to
1008 * the window, if it's being activated and not minimized */
1009 if (LOWORD(wParam) != WA_INACTIVE &&
1010 !(Wnd->style & WS_MINIMIZE))
1011 {
1012 //ERR("WM_ACTIVATE %p\n",hWnd);
1013 co_UserSetFocus(Wnd);
1014 }
1015 break;
1016
1017 case WM_MOUSEWHEEL:
1018 if (Wnd->style & WS_CHILD)
1019 {
1020 HWND hwndParent;
1021 PWND pwndParent = IntGetParent(Wnd);
1022 hwndParent = pwndParent ? UserHMGetHandle(pwndParent) : NULL;
1023 return co_IntSendMessage( hwndParent, WM_MOUSEWHEEL, wParam, lParam);
1024 }
1025 break;
1026
1027 case WM_ERASEBKGND:
1028 case WM_ICONERASEBKGND:
1029 {
1030 RECT Rect;
1031 HBRUSH hBrush = Wnd->pcls->hbrBackground;
1032 if (!hBrush) return 0;
1033 if (hBrush <= (HBRUSH)COLOR_MENUBAR)
1034 {
1035 hBrush = IntGetSysColorBrush(HandleToUlong(hBrush));
1036 }
1037 if (Wnd->pcls->style & CS_PARENTDC)
1038 {
1039 /* can't use GetClipBox with a parent DC or we fill the whole parent */
1040 IntGetClientRect(Wnd, &Rect);
1041 GreDPtoLP((HDC)wParam, (LPPOINT)&Rect, 2);
1042 }
1043 else
1044 {
1045 GdiGetClipBox((HDC)wParam, &Rect);
1046 }
1047 FillRect((HDC)wParam, &Rect, hBrush);
1048 return (1);
1049 }
1050
1051 case WM_GETHOTKEY:
1052 //ERR("WM_GETHOTKEY\n");
1053 return DefWndGetHotKey(Wnd);
1054 case WM_SETHOTKEY:
1055 //ERR("WM_SETHOTKEY\n");
1056 return DefWndSetHotKey(Wnd, wParam);
1057
1058 case WM_NCHITTEST:
1059 {
1060 POINT Point;
1061 Point.x = GET_X_LPARAM(lParam);
1062 Point.y = GET_Y_LPARAM(lParam);
1063 return GetNCHitEx(Wnd, Point);
1064 }
1065
1066 case WM_PRINT:
1067 {
1068 DefWndPrint(Wnd, (HDC)wParam, lParam);
1069 return (0);
1070 }
1071
1072 case WM_SYSCOLORCHANGE:
1073 {
1074 /* force to redraw non-client area */
1075 UserPaintCaption(Wnd, DC_NC);
1076 /* Use InvalidateRect to redraw client area, enable
1077 * erase to redraw all subcontrols otherwise send the
1078 * WM_SYSCOLORCHANGE to child windows/controls is required
1079 */
1080 co_UserRedrawWindow( Wnd, NULL, NULL, RDW_ALLCHILDREN|RDW_INVALIDATE|RDW_ERASE);
1081 return (0);
1082 }
1083
1084 case WM_PAINTICON:
1085 case WM_PAINT:
1086 {
1087 PAINTSTRUCT Ps;
1088 HDC hDC;
1089
1090 /* If already in Paint and Client area is not empty just return. */
1091 if (Wnd->state2 & WNDS2_STARTPAINT && !RECTL_bIsEmptyRect(&Wnd->rcClient))
1092 {
1093 ERR("In Paint and Client area is not empty!\n");
1094 return 0;
1095 }
1096
1097 hDC = IntBeginPaint(Wnd, &Ps);
1098 if (hDC)
1099 {
1100 if (((Wnd->style & WS_MINIMIZE) != 0) && (Wnd->pcls->spicn))
1101 {
1102 RECT ClientRect;
1103 INT x, y;
1104
1105 ERR("Doing Paint and Client area is empty!\n");
1106 IntGetClientRect(Wnd, &ClientRect);
1107 x = (ClientRect.right - ClientRect.left - UserGetSystemMetrics(SM_CXICON)) / 2;
1108 y = (ClientRect.bottom - ClientRect.top - UserGetSystemMetrics(SM_CYICON)) / 2;
1109 UserReferenceObject(Wnd->pcls->spicn);
1110 UserDrawIconEx(hDC, x, y, Wnd->pcls->spicn, 0, 0, 0, 0, DI_NORMAL | DI_COMPAT | DI_DEFAULTSIZE);
1111 UserDereferenceObject(Wnd->pcls->spicn);
1112 }
1113
1114 IntEndPaint(Wnd, &Ps);
1115 }
1116 return (0);
1117 }
1118
1119 case WM_SYNCPAINT:
1120 {
1121 HRGN hRgn;
1122 Wnd->state &= ~WNDS_SYNCPAINTPENDING;
1123 TRACE("WM_SYNCPAINT\n");
1124 hRgn = NtGdiCreateRectRgn(0, 0, 0, 0);
1125 if (hRgn)
1126 {
1127 if (co_UserGetUpdateRgn(Wnd, hRgn, FALSE) != NULLREGION)
1128 {
1129 PREGION pRgn = REGION_LockRgn(hRgn);
1130 if (pRgn) REGION_UnlockRgn(pRgn);
1131 if (!wParam)
1132 wParam = (RDW_ERASENOW | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN);
1133 co_UserRedrawWindow(Wnd, NULL, pRgn, wParam);
1134 }
1135 GreDeleteObject(hRgn);
1136 }
1137 return 0;
1138 }
1139
1140 case WM_SETREDRAW:
1141 if (wParam)
1142 {
1143 if (!(Wnd->style & WS_VISIBLE))
1144 {
1145 IntSetStyle( Wnd, WS_VISIBLE, 0 );
1146 Wnd->state |= WNDS_SENDNCPAINT;
1147 }
1148 }
1149 else
1150 {
1151 if (Wnd->style & WS_VISIBLE)
1152 {
1153 co_UserRedrawWindow( Wnd, NULL, NULL, RDW_ALLCHILDREN | RDW_VALIDATE );
1154 IntSetStyle( Wnd, 0, WS_VISIBLE );
1155 }
1156 }
1157 return 0;
1158
1159 case WM_WINDOWPOSCHANGING:
1160 {
1161 return (DefWndHandleWindowPosChanging(Wnd, (WINDOWPOS*)lParam));
1162 }
1163
1164 case WM_WINDOWPOSCHANGED:
1165 {
1166 return (DefWndHandleWindowPosChanged(Wnd, (WINDOWPOS*)lParam));
1167 }
1168
1169 case WM_NCCALCSIZE:
1170 {
1171 return NC_HandleNCCalcSize( Wnd, wParam, (RECTL *)lParam, FALSE );
1172 }
1173
1174 case WM_NCACTIVATE:
1175 {
1176 return NC_HandleNCActivate( Wnd, wParam, lParam );
1177 }
1178
1179 //
1180 // NC Paint mode.
1181 //
1182 case WM_NCPAINT:
1183 {
1184 HDC hDC = UserGetDCEx(Wnd, (HRGN)wParam, DCX_WINDOW | DCX_INTERSECTRGN | DCX_USESTYLE | DCX_KEEPCLIPRGN);
1185 Wnd->state |= WNDS_FORCEMENUDRAW;
1186 NC_DoNCPaint(Wnd, hDC, -1);
1187 Wnd->state &= ~WNDS_FORCEMENUDRAW;
1188 UserReleaseDC(Wnd, hDC, FALSE);
1189 return 0;
1190 }
1191 //
1192 // Draw Caption mode.
1193 //
1194 // wParam are DC_* flags.
1195 //
1196 case WM_NCUAHDRAWCAPTION:
1197 {
1198 HDC hDC = UserGetDCEx(Wnd, NULL, DCX_WINDOW|DCX_USESTYLE);
1199 TRACE("WM_NCUAHDRAWCAPTION: wParam DC_ flags %08x\n",wParam);
1200 UserDrawCaptionBar(Wnd, hDC, wParam | DC_FRAME); // Include DC_FRAME to comp for drawing glitch.
1201 UserReleaseDC(Wnd, hDC, FALSE);
1202 return 0;
1203 }
1204 //
1205 // Draw Frame mode.
1206 //
1207 // wParam is HDC, lParam are DC_ACTIVE and or DC_REDRAWHUNGWND.
1208 //
1209 case WM_NCUAHDRAWFRAME:
1210 {
1211 TRACE("WM_NCUAHDRAWFRAME: wParam hDC %p lParam DC_ flags %08x\n",wParam,lParam);
1212 NC_DoNCPaint(Wnd, (HDC)wParam, lParam|DC_NC);
1213 return 0;
1214 }
1215
1216 /* ReactOS only. */
1217 case WM_CBT:
1218 {
1219 switch (wParam)
1220 {
1221 case HCBT_MOVESIZE:
1222 {
1223 RECTL rt;
1224
1225 if (lParam)
1226 {
1227 _SEH2_TRY
1228 {
1229 ProbeForRead((PVOID)lParam,
1230 sizeof(RECT),
1231 1);
1232
1233 RtlCopyMemory(&rt,
1234 (PVOID)lParam,
1235 sizeof(RECT));
1236 }
1237 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
1238 {
1239 lResult = 1;
1240 }
1241 _SEH2_END;
1242 }
1243 if (!lResult)
1244 lResult = co_HOOK_CallHooks(WH_CBT, HCBT_MOVESIZE, (WPARAM)UserHMGetHandle(Wnd), lParam ? (LPARAM)&rt : 0);
1245
1246 break;
1247 }
1248 }
1249 break;
1250 }
1251 }
1252 return lResult;
1253 }
1254
1255 /* EOF */
1256