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/defwnd.c 6 * PROGRAMER: 7 */ 8 9 #include <win32k.h> 10 #include <windowsx.h> 11 12 DBG_DEFAULT_CHANNEL(UserDefwnd); 13 14 INT WINAPI DrawTextExWorker( HDC hdc, LPWSTR str, INT i_count, 15 LPRECT rect, UINT flags, LPDRAWTEXTPARAMS dtp ); 16 17 INT WINAPI DrawTextW( HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags ) 18 { 19 DRAWTEXTPARAMS dtp; 20 21 memset (&dtp, 0, sizeof(dtp)); 22 dtp.cbSize = sizeof(dtp); 23 if (flags & DT_TABSTOP) 24 { 25 dtp.iTabLength = (flags >> 8) & 0xff; 26 flags &= 0xffff00ff; 27 } 28 return DrawTextExWorker(hdc, (LPWSTR)str, count, rect, flags, &dtp); 29 } 30 31 32 HBRUSH FASTCALL 33 DefWndControlColor(HDC hDC, UINT ctlType) 34 { 35 if (ctlType == CTLCOLOR_SCROLLBAR) 36 { 37 HBRUSH hb = IntGetSysColorBrush(COLOR_SCROLLBAR); 38 COLORREF bk = IntGetSysColor(COLOR_3DHILIGHT); 39 IntGdiSetTextColor(hDC, IntGetSysColor(COLOR_3DFACE)); 40 IntGdiSetBkColor(hDC, bk); 41 42 /* if COLOR_WINDOW happens to be the same as COLOR_3DHILIGHT 43 * we better use 0x55aa bitmap brush to make scrollbar's background 44 * look different from the window background. 45 */ 46 if ( bk == IntGetSysColor(COLOR_WINDOW)) 47 return gpsi->hbrGray; 48 49 NtGdiUnrealizeObject( hb ); 50 return hb; 51 } 52 53 IntGdiSetTextColor(hDC, IntGetSysColor(COLOR_WINDOWTEXT)); 54 55 if ((ctlType == CTLCOLOR_EDIT) || (ctlType == CTLCOLOR_LISTBOX)) 56 { 57 IntGdiSetBkColor(hDC, IntGetSysColor(COLOR_WINDOW)); 58 } 59 else 60 { 61 IntGdiSetBkColor(hDC, IntGetSysColor(COLOR_3DFACE)); 62 return IntGetSysColorBrush(COLOR_3DFACE); 63 } 64 65 return IntGetSysColorBrush(COLOR_WINDOW); 66 } 67 68 LRESULT FASTCALL 69 DefWndHandleWindowPosChanging(PWND pWnd, WINDOWPOS* Pos) 70 { 71 POINT maxTrack, minTrack; 72 LONG style = pWnd->style; 73 74 if (Pos->flags & SWP_NOSIZE) return 0; 75 if ((style & WS_THICKFRAME) || ((style & (WS_POPUP | WS_CHILD)) == 0)) 76 { 77 co_WinPosGetMinMaxInfo(pWnd, NULL, NULL, &minTrack, &maxTrack); 78 Pos->cx = min(Pos->cx, maxTrack.x); 79 Pos->cy = min(Pos->cy, maxTrack.y); 80 if (!(style & WS_MINIMIZE)) 81 { 82 if (Pos->cx < minTrack.x) Pos->cx = minTrack.x; 83 if (Pos->cy < minTrack.y) Pos->cy = minTrack.y; 84 } 85 } 86 else 87 { 88 Pos->cx = max(Pos->cx, 0); 89 Pos->cy = max(Pos->cy, 0); 90 } 91 return 0; 92 } 93 94 LRESULT FASTCALL 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 LRESULT FASTCALL 124 DefWndHandleSysCommand(PWND pWnd, WPARAM wParam, LPARAM lParam) 125 { 126 LRESULT lResult = 0; 127 BOOL Hook = FALSE; 128 129 if (ISITHOOKED(WH_CBT) || (pWnd->head.rpdesk->pDeskInfo->fsHooks & HOOKID_TO_FLAG(WH_CBT))) 130 { 131 Hook = TRUE; 132 lResult = co_HOOK_CallHooks(WH_CBT, HCBT_SYSCOMMAND, wParam, lParam); 133 134 if (lResult) return lResult; 135 } 136 137 switch (wParam & 0xfff0) 138 { 139 case SC_MOVE: 140 case SC_SIZE: 141 DefWndDoSizeMove(pWnd, wParam); 142 break; 143 144 case SC_MINIMIZE: 145 if (UserHMGetHandle(pWnd) == UserGetActiveWindow()) 146 IntShowOwnedPopups(pWnd,FALSE); // This is done in ShowWindow! Need to retest! 147 co_WinPosShowWindow( pWnd, SW_MINIMIZE ); 148 break; 149 150 case SC_MAXIMIZE: 151 if (((pWnd->style & WS_MINIMIZE) != 0) && UserHMGetHandle(pWnd) == UserGetActiveWindow()) 152 IntShowOwnedPopups(pWnd,TRUE); 153 co_WinPosShowWindow( pWnd, SW_MAXIMIZE ); 154 break; 155 156 case SC_RESTORE: 157 if (((pWnd->style & WS_MINIMIZE) != 0) && UserHMGetHandle(pWnd) == UserGetActiveWindow()) 158 IntShowOwnedPopups(pWnd,TRUE); 159 co_WinPosShowWindow( pWnd, SW_RESTORE ); 160 break; 161 162 case SC_CLOSE: 163 return co_IntSendMessage(UserHMGetHandle(pWnd), WM_CLOSE, 0, 0); 164 165 case SC_SCREENSAVE: 166 ERR("Screensaver Called!\n"); 167 UserPostMessage(hwndSAS, WM_LOGONNOTIFY, LN_START_SCREENSAVE, 0); // always lParam 0 == not Secure 168 break; 169 170 case SC_HOTKEY: 171 { 172 USER_REFERENCE_ENTRY Ref; 173 174 pWnd = ValidateHwndNoErr((HWND)lParam); 175 if (pWnd) 176 { 177 if (pWnd->spwndLastActive) 178 { 179 pWnd = pWnd->spwndLastActive; 180 } 181 UserRefObjectCo(pWnd, &Ref); 182 co_IntSetForegroundWindow(pWnd); 183 UserDerefObjectCo(pWnd); 184 if (pWnd->style & WS_MINIMIZE) 185 { 186 UserPostMessage(UserHMGetHandle(pWnd), WM_SYSCOMMAND, SC_RESTORE, 0); 187 } 188 } 189 } 190 break; 191 // case SC_DEFAULT: 192 case SC_MOUSEMENU: 193 { 194 POINT Pt; 195 Pt.x = (short)LOWORD(lParam); 196 Pt.y = (short)HIWORD(lParam); 197 MENU_TrackMouseMenuBar(pWnd, wParam & 0x000f, Pt); 198 } 199 break; 200 201 case SC_KEYMENU: 202 MENU_TrackKbdMenuBar(pWnd, wParam, (WCHAR)lParam); 203 break; 204 205 206 default: 207 // We do not support anything else here so we should return normal even when sending a hook. 208 return 0; 209 } 210 211 return(Hook ? 1 : 0); // Don't call us again from user space. 212 } 213 214 PWND FASTCALL 215 co_IntFindChildWindowToOwner(PWND Root, PWND Owner) 216 { 217 PWND Ret; 218 PWND Child, OwnerWnd; 219 220 for(Child = Root->spwndChild; Child; Child = Child->spwndNext) 221 { 222 OwnerWnd = Child->spwndOwner; 223 if(!OwnerWnd) 224 continue; 225 226 if (!(Child->style & WS_POPUP) || 227 !(Child->style & WS_VISIBLE) || 228 /* Fixes CMD pop up properties window from having foreground. */ 229 Owner->head.pti->MessageQueue != Child->head.pti->MessageQueue) 230 continue; 231 232 if(OwnerWnd == Owner) 233 { 234 Ret = Child; 235 return Ret; 236 } 237 } 238 return NULL; 239 } 240 241 LRESULT 242 DefWndHandleSetCursor(PWND pWnd, WPARAM wParam, LPARAM lParam) 243 { 244 PWND pwndPopUP = NULL; 245 WORD Msg = HIWORD(lParam); 246 247 /* Not for child windows. */ 248 if (UserHMGetHandle(pWnd) != (HWND)wParam) 249 { 250 return FALSE; 251 } 252 253 switch((short)LOWORD(lParam)) 254 { 255 case HTERROR: 256 { 257 //// This is the real fix for CORE-6129! This was a "Code hole". 258 USER_REFERENCE_ENTRY Ref; 259 260 if (Msg == WM_LBUTTONDOWN) 261 { 262 // Find a pop up window to bring active. 263 pwndPopUP = co_IntFindChildWindowToOwner(UserGetDesktopWindow(), pWnd); 264 if (pwndPopUP) 265 { 266 // Not a child pop up from desktop. 267 if ( pwndPopUP != UserGetDesktopWindow()->spwndChild ) 268 { 269 // Get original active window. 270 PWND pwndOrigActive = gpqForeground->spwndActive; 271 272 co_WinPosSetWindowPos(pWnd, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); 273 274 UserRefObjectCo(pwndPopUP, &Ref); 275 //UserSetActiveWindow(pwndPopUP); 276 co_IntSetForegroundWindow(pwndPopUP); // HACK 277 UserDerefObjectCo(pwndPopUP); 278 279 // If the change was made, break out. 280 if (pwndOrigActive != gpqForeground->spwndActive) 281 break; 282 } 283 } 284 } 285 //// 286 if (Msg == WM_LBUTTONDOWN || Msg == WM_MBUTTONDOWN || 287 Msg == WM_RBUTTONDOWN || Msg == WM_XBUTTONDOWN) 288 { 289 if (pwndPopUP) 290 { 291 FLASHWINFO fwi = 292 {sizeof(FLASHWINFO), 293 UserHMGetHandle(pwndPopUP), 294 FLASHW_ALL, 295 gspv.dwForegroundFlashCount, 296 (gpsi->dtCaretBlink >> 3)}; 297 298 // Now shake that window! 299 IntFlashWindowEx(pwndPopUP, &fwi); 300 } 301 UserPostMessage(hwndSAS, WM_LOGONNOTIFY, LN_MESSAGE_BEEP, 0); 302 } 303 break; 304 } 305 306 case HTCLIENT: 307 { 308 if (pWnd->pcls->spcur) 309 { 310 IntSystemSetCursor(pWnd->pcls->spcur); 311 } 312 return FALSE; 313 } 314 315 case HTLEFT: 316 case HTRIGHT: 317 { 318 if (pWnd->style & WS_MAXIMIZE) 319 { 320 break; 321 } 322 IntSystemSetCursor(SYSTEMCUR(SIZEWE)); 323 return TRUE; 324 } 325 326 case HTTOP: 327 case HTBOTTOM: 328 { 329 if (pWnd->style & WS_MAXIMIZE) 330 { 331 break; 332 } 333 IntSystemSetCursor(SYSTEMCUR(SIZENS)); 334 return TRUE; 335 } 336 337 case HTTOPLEFT: 338 case HTBOTTOMRIGHT: 339 { 340 if (pWnd->style & WS_MAXIMIZE) 341 { 342 break; 343 } 344 IntSystemSetCursor(SYSTEMCUR(SIZENWSE)); 345 return TRUE; 346 } 347 348 case HTBOTTOMLEFT: 349 case HTTOPRIGHT: 350 { 351 if (pWnd->style & WS_MAXIMIZE) 352 { 353 break; 354 } 355 IntSystemSetCursor(SYSTEMCUR(SIZENESW)); 356 return TRUE; 357 } 358 } 359 IntSystemSetCursor(SYSTEMCUR(ARROW)); 360 return FALSE; 361 } 362 363 VOID FASTCALL DefWndPrint( PWND pwnd, HDC hdc, ULONG uFlags) 364 { 365 /* 366 * Visibility flag. 367 */ 368 if ( (uFlags & PRF_CHECKVISIBLE) && 369 !IntIsWindowVisible(pwnd) ) 370 return; 371 372 /* 373 * Unimplemented flags. 374 */ 375 if ( (uFlags & PRF_CHILDREN) || 376 (uFlags & PRF_OWNED) || 377 (uFlags & PRF_NONCLIENT) ) 378 { 379 FIXME("WM_PRINT message with unsupported flags\n"); 380 } 381 382 /* 383 * Background 384 */ 385 if ( uFlags & PRF_ERASEBKGND) 386 co_IntSendMessage(UserHMGetHandle(pwnd), WM_ERASEBKGND, (WPARAM)hdc, 0); 387 388 /* 389 * Client area 390 */ 391 if ( uFlags & PRF_CLIENT) 392 co_IntSendMessage(UserHMGetHandle(pwnd), WM_PRINTCLIENT, (WPARAM)hdc, uFlags); 393 } 394 395 BOOL 396 UserPaintCaption(PWND pWnd, INT Flags) 397 { 398 BOOL Ret = FALSE; 399 400 if ( (pWnd->style & WS_VISIBLE) && ((pWnd->style & WS_CAPTION) == WS_CAPTION) ) 401 { 402 if (pWnd->state & WNDS_HASCAPTION && pWnd->head.pti->MessageQueue == gpqForeground) 403 Flags |= DC_ACTIVE; 404 /* 405 * When themes are not enabled we can go on and paint the non client area. 406 * However if we do that with themes enabled we will draw a classic frame. 407 * This is solved by sending a themes specific message to notify the themes 408 * engine that the caption needs to be redrawn 409 */ 410 if (gpsi->dwSRVIFlags & SRVINFO_APIHOOK) 411 { 412 /* 413 * This will cause uxtheme to either paint the themed caption or call 414 * RealUserDrawCaption in order to draw the classic caption when themes 415 * are disabled but the themes service is enabled 416 */ 417 TRACE("UDCB Flags %08x\n", Flags); 418 co_IntSendMessage(UserHMGetHandle(pWnd), WM_NCUAHDRAWCAPTION, Flags, 0); 419 } 420 else 421 { 422 HDC hDC = UserGetDCEx(pWnd, NULL, DCX_WINDOW|DCX_USESTYLE); 423 UserDrawCaptionBar(pWnd, hDC, Flags | DC_FRAME); // DCFRAME added as fix for CORE-10855. 424 UserReleaseDC(pWnd, hDC, FALSE); 425 } 426 Ret = TRUE; 427 } 428 // Support window tray 429 return Ret; 430 } 431 432 // WM_SETICON 433 LRESULT FASTCALL 434 DefWndSetIcon(PWND pWnd, WPARAM wParam, LPARAM lParam) 435 { 436 HICON hIcon, hIconSmall, hIconOld; 437 438 if ( wParam > ICON_SMALL2 ) 439 { 440 EngSetLastError(ERROR_INVALID_PARAMETER); 441 return 0; 442 } 443 hIconSmall = UserGetProp(pWnd, gpsi->atomIconSmProp, TRUE); 444 hIcon = UserGetProp(pWnd, gpsi->atomIconProp, TRUE); 445 446 hIconOld = wParam == ICON_BIG ? hIcon : hIconSmall; 447 448 switch(wParam) 449 { 450 case ICON_BIG: 451 hIcon = (HICON)lParam; 452 break; 453 case ICON_SMALL: 454 hIconSmall = (HICON)lParam; 455 break; 456 case ICON_SMALL2: 457 ERR("FIXME: Set ICON_SMALL2 support!\n"); 458 default: 459 break; 460 } 461 462 UserSetProp(pWnd, gpsi->atomIconProp, hIcon, TRUE); 463 UserSetProp(pWnd, gpsi->atomIconSmProp, hIconSmall, TRUE); 464 465 if ((pWnd->style & WS_CAPTION ) == WS_CAPTION) 466 UserPaintCaption(pWnd, DC_ICON); 467 468 return (LRESULT)hIconOld; 469 } 470 471 LRESULT FASTCALL 472 DefWndGetIcon(PWND pWnd, WPARAM wParam, LPARAM lParam) 473 { 474 HICON hIconRet; 475 if ( wParam > ICON_SMALL2 ) 476 { 477 EngSetLastError(ERROR_INVALID_PARAMETER); 478 return 0; 479 } 480 switch(wParam) 481 { 482 case ICON_BIG: 483 hIconRet = UserGetProp(pWnd, gpsi->atomIconProp, TRUE); 484 break; 485 case ICON_SMALL: 486 case ICON_SMALL2: 487 hIconRet = UserGetProp(pWnd, gpsi->atomIconSmProp, TRUE); 488 break; 489 DEFAULT_UNREACHABLE; 490 } 491 return (LRESULT)hIconRet; 492 } 493 494 VOID FASTCALL 495 DefWndScreenshot(PWND pWnd) 496 { 497 RECT rect; 498 HDC hdc; 499 INT w; 500 INT h; 501 HBITMAP hbitmap; 502 HDC hdc2; 503 SETCLIPBDATA scd = {FALSE, FALSE}; 504 505 UserOpenClipboard(UserHMGetHandle(pWnd)); 506 UserEmptyClipboard(); 507 508 hdc = UserGetWindowDC(pWnd); 509 IntGetWindowRect(pWnd, &rect); 510 w = rect.right - rect.left; 511 h = rect.bottom - rect.top; 512 513 hbitmap = NtGdiCreateCompatibleBitmap(hdc, w, h); 514 hdc2 = NtGdiCreateCompatibleDC(hdc); 515 NtGdiSelectBitmap(hdc2, hbitmap); 516 517 NtGdiBitBlt(hdc2, 0, 0, w, h, hdc, 0, 0, SRCCOPY, 0, 0); 518 519 UserSetClipboardData(CF_BITMAP, hbitmap, &scd); 520 521 UserReleaseDC(pWnd, hdc, FALSE); 522 UserReleaseDC(pWnd, hdc2, FALSE); 523 524 UserCloseClipboard(); 525 } 526 527 /* 528 Win32k counterpart of User DefWindowProc 529 */ 530 LRESULT FASTCALL 531 IntDefWindowProc( 532 PWND Wnd, 533 UINT Msg, 534 WPARAM wParam, 535 LPARAM lParam, 536 BOOL Ansi) 537 { 538 PTHREADINFO pti = PsGetCurrentThreadWin32Thread(); 539 LRESULT lResult = 0; 540 USER_REFERENCE_ENTRY Ref; 541 BOOL IsTaskBar; 542 DWORD Style; 543 DWORD ExStyle; 544 545 if (Msg > WM_USER) return 0; 546 547 switch (Msg) 548 { 549 case WM_DEVICECHANGE: 550 return TRUE; 551 552 case WM_GETTEXTLENGTH: 553 { 554 PWSTR buf; 555 ULONG len; 556 557 if (Wnd != NULL && Wnd->strName.Length != 0) 558 { 559 buf = Wnd->strName.Buffer; 560 if (buf != NULL && 561 NT_SUCCESS(RtlUnicodeToMultiByteSize(&len, 562 buf, 563 Wnd->strName.Length))) 564 { 565 lResult = (LRESULT) (Wnd->strName.Length / sizeof(WCHAR)); 566 } 567 } 568 else lResult = 0L; 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", Wnd->head.h, 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, 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 (IS_KEY_DOWN(gafAsyncKeyState, VK_LWIN) || IS_KEY_DOWN(gafAsyncKeyState, VK_RWIN)) 790 { 791 HWND hwndTop = UserGetForegroundWindow(); 792 PWND topWnd = UserGetWindowObject(hwndTop); 793 794 /* Test for typical TaskBar ExStyle Values */ 795 ExStyle = (topWnd->ExStyle & WS_EX_TOOLWINDOW); 796 TRACE("ExStyle is '%x'.\n", ExStyle); 797 798 /* Test for typical TaskBar Style Values */ 799 Style = (topWnd->style & (WS_POPUP | WS_VISIBLE | 800 WS_CLIPSIBLINGS | WS_CLIPCHILDREN)); 801 TRACE("Style is '%x'.\n", Style); 802 803 /* Test for masked typical TaskBar Style and ExStyles to detect TaskBar */ 804 IsTaskBar = (Style == (WS_POPUP | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN)) 805 && (ExStyle == WS_EX_TOOLWINDOW); 806 TRACE("This %s the TaskBar.\n", IsTaskBar ? "is" : "is not"); 807 808 if (topWnd && !IsTaskBar) /* Second test is so we are not touching the Taskbar */ 809 { 810 if ((topWnd->style & WS_THICKFRAME) == 0) 811 { 812 return 0; 813 } 814 815 if (wParam == VK_DOWN) 816 { 817 if (topWnd->style & WS_MAXIMIZE) 818 { 819 co_IntSendMessage(hwndTop, WM_SYSCOMMAND, SC_RESTORE, lParam); 820 821 /* "Normal size" must be erased after restoring, otherwise it will block next side snap actions */ 822 RECTL_vSetEmptyRect(&topWnd->InternalPos.NormalRect); 823 } 824 else 825 { 826 co_IntSendMessage(hwndTop, WM_SYSCOMMAND, SC_MINIMIZE, lParam); 827 } 828 } 829 else if (wParam == VK_UP) 830 { 831 RECT currentRect; 832 if ((topWnd->InternalPos.NormalRect.right == topWnd->InternalPos.NormalRect.left) || 833 (topWnd->InternalPos.NormalRect.top == topWnd->InternalPos.NormalRect.bottom)) 834 { 835 currentRect = topWnd->rcWindow; 836 } 837 else 838 { 839 currentRect = topWnd->InternalPos.NormalRect; 840 } 841 co_IntSendMessage(hwndTop, WM_SYSCOMMAND, SC_MAXIMIZE, 0); 842 843 // save normal rect if maximazing snapped window 844 topWnd->InternalPos.NormalRect = currentRect; 845 } 846 else if (wParam == VK_LEFT || wParam == VK_RIGHT) 847 { 848 RECT snapRect, normalRect, windowRect; 849 BOOL snapped; 850 normalRect = topWnd->InternalPos.NormalRect; 851 snapped = (normalRect.left != 0 && normalRect.right != 0 && 852 normalRect.top != 0 && normalRect.bottom != 0); 853 854 if (topWnd->style & WS_MAXIMIZE) 855 { 856 co_IntSendMessage(hwndTop, WM_SYSCOMMAND, SC_RESTORE, lParam); 857 snapped = FALSE; 858 } 859 windowRect = topWnd->rcWindow; 860 861 UserSystemParametersInfo(SPI_GETWORKAREA, 0, &snapRect, 0); 862 if (wParam == VK_LEFT) 863 { 864 snapRect.right = (snapRect.left + snapRect.right) / 2; 865 } 866 else // VK_RIGHT 867 { 868 snapRect.left = (snapRect.left + snapRect.right) / 2; 869 } 870 871 if (snapped) 872 { 873 // if window was snapped but moved to other location - restore normal size 874 if (!IntEqualRect(&snapRect, &windowRect)) 875 { 876 RECT empty = {0, 0, 0, 0}; 877 co_WinPosSetWindowPos(topWnd, 878 0, 879 normalRect.left, 880 normalRect.top, 881 normalRect.right - normalRect.left, 882 normalRect.bottom - normalRect.top, 883 0); 884 topWnd->InternalPos.NormalRect = empty; 885 } 886 } 887 else 888 { 889 co_WinPosSetWindowPos(topWnd, 890 0, 891 snapRect.left, 892 snapRect.top, 893 snapRect.right - snapRect.left, 894 snapRect.bottom - snapRect.top, 895 0); 896 topWnd->InternalPos.NormalRect = windowRect; 897 } 898 } 899 } 900 } 901 break; 902 903 case WM_SYSKEYDOWN: 904 { 905 if (HIWORD(lParam) & KF_ALTDOWN) 906 { /* Previous state, if the key was down before this message, 907 this is a cheap way to ignore autorepeat keys. */ 908 if ( !(HIWORD(lParam) & KF_REPEAT) ) 909 { 910 if ( ( wParam == VK_MENU || 911 wParam == VK_LMENU || 912 wParam == VK_RMENU ) && !(pti->MessageQueue->QF_flags & QF_FMENUSTATUS)) //iMenuSysKey ) 913 pti->MessageQueue->QF_flags |= QF_FMENUSTATUS; //iMenuSysKey = 1; 914 else 915 pti->MessageQueue->QF_flags &= ~QF_FMENUSTATUS; //iMenuSysKey = 0; 916 } 917 918 pti->MessageQueue->QF_flags &= ~QF_FF10STATUS; //iF10Key = 0; 919 920 if (wParam == VK_F4) /* Try to close the window */ 921 { 922 PWND top = UserGetAncestor(Wnd, GA_ROOT); 923 if (!(top->style & CS_NOCLOSE)) 924 UserPostMessage(UserHMGetHandle(top), WM_SYSCOMMAND, SC_CLOSE, 0); 925 } 926 else if (wParam == VK_SNAPSHOT) // Alt-VK_SNAPSHOT? 927 { 928 PWND pwnd = Wnd; 929 while (IntGetParent(pwnd) != NULL) 930 { 931 pwnd = IntGetParent(pwnd); 932 } 933 ERR("DefWndScreenshot\n"); 934 DefWndScreenshot(pwnd); 935 } 936 else if ( wParam == VK_ESCAPE || wParam == VK_TAB ) // Alt-Tab/ESC Alt-Shift-Tab/ESC 937 { 938 WPARAM wParamTmp; 939 HWND Active = UserGetActiveWindow(); // Noticed MDI problem. 940 if (!Active) 941 { 942 FIXME("WM_SYSKEYDOWN VK_ESCAPE no active\n"); 943 break; 944 } 945 wParamTmp = UserGetKeyState(VK_SHIFT) & 0x8000 ? SC_PREVWINDOW : SC_NEXTWINDOW; 946 co_IntSendMessage( Active, WM_SYSCOMMAND, wParamTmp, wParam ); 947 } 948 } 949 else if( wParam == VK_F10 ) 950 { 951 if (UserGetKeyState(VK_SHIFT) & 0x8000) 952 co_IntSendMessage( UserHMGetHandle(Wnd), WM_CONTEXTMENU, (WPARAM)UserHMGetHandle(Wnd), MAKELPARAM(-1, -1) ); 953 pti->MessageQueue->QF_flags |= QF_FF10STATUS; //iF10Key = 1; 954 } 955 else if( wParam == VK_ESCAPE && (UserGetKeyState(VK_SHIFT) & 0x8000)) 956 co_IntSendMessage( UserHMGetHandle(Wnd), WM_SYSCOMMAND, SC_KEYMENU, ' ' ); 957 break; 958 } 959 960 case WM_KEYUP: 961 case WM_SYSKEYUP: 962 { 963 /* Press and release F10 or ALT */ 964 if (((wParam == VK_MENU || wParam == VK_LMENU || wParam == VK_RMENU) 965 && (pti->MessageQueue->QF_flags & (QF_FMENUSTATUS|QF_FMENUSTATUSBREAK)) == QF_FMENUSTATUS /*iMenuSysKey*/) || 966 ((wParam == VK_F10) && pti->MessageQueue->QF_flags & QF_FF10STATUS /*iF10Key*/)) 967 co_IntSendMessage( UserHMGetHandle(UserGetAncestor( Wnd, GA_ROOT )), WM_SYSCOMMAND, SC_KEYMENU, 0L ); 968 pti->MessageQueue->QF_flags &= ~(QF_FMENUSTATUS|QF_FMENUSTATUSBREAK|QF_FF10STATUS); //iMenuSysKey = iF10Key = 0; 969 break; 970 } 971 972 case WM_SYSCHAR: 973 { 974 pti->MessageQueue->QF_flags &= ~(QF_FMENUSTATUS|QF_FMENUSTATUSBREAK); //iMenuSysKey = 0; 975 if (wParam == VK_RETURN && (Wnd->style & WS_MINIMIZE) != 0) 976 { 977 UserPostMessage( UserHMGetHandle(Wnd), WM_SYSCOMMAND, SC_RESTORE, 0L ); 978 break; 979 } 980 if ((HIWORD(lParam) & KF_ALTDOWN) && wParam) 981 { 982 if (wParam == VK_TAB || wParam == VK_ESCAPE) break; 983 if (wParam == VK_SPACE && Wnd->style & WS_CHILD) 984 co_IntSendMessage( UserHMGetHandle(IntGetParent(Wnd)), Msg, wParam, lParam ); 985 else 986 co_IntSendMessage( UserHMGetHandle(Wnd), WM_SYSCOMMAND, SC_KEYMENU, wParam ); 987 } 988 else /* check for Ctrl-Esc */ 989 if (wParam != VK_ESCAPE) UserPostMessage(hwndSAS, WM_LOGONNOTIFY, LN_MESSAGE_BEEP, 0); //MessageBeep(0); 990 break; 991 } 992 993 case WM_CANCELMODE: 994 { 995 pti->MessageQueue->QF_flags &= ~(QF_FMENUSTATUS|QF_FMENUSTATUSBREAK); 996 997 MENU_EndMenu( Wnd ); 998 if (IntGetCaptureWindow() == UserHMGetHandle(Wnd)) 999 { 1000 IntReleaseCapture(); 1001 } 1002 break; 1003 } 1004 1005 case WM_CLOSE: 1006 co_UserDestroyWindow(Wnd); 1007 break; 1008 1009 case WM_CTLCOLORMSGBOX: 1010 case WM_CTLCOLOREDIT: 1011 case WM_CTLCOLORLISTBOX: 1012 case WM_CTLCOLORBTN: 1013 case WM_CTLCOLORDLG: 1014 case WM_CTLCOLORSTATIC: 1015 case WM_CTLCOLORSCROLLBAR: 1016 return (LRESULT) DefWndControlColor((HDC)wParam, Msg - WM_CTLCOLORMSGBOX); 1017 1018 case WM_CTLCOLOR: 1019 return (LRESULT) DefWndControlColor((HDC)wParam, HIWORD(lParam)); 1020 1021 case WM_SETCURSOR: 1022 { 1023 if (Wnd->style & WS_CHILD) 1024 { 1025 /* with the exception of the border around a resizable wnd, 1026 * give the parent first chance to set the cursor */ 1027 if (LOWORD(lParam) < HTLEFT || LOWORD(lParam) > HTBOTTOMRIGHT) 1028 { 1029 PWND parent = Wnd->spwndParent;//IntGetParent( Wnd ); 1030 if (parent != UserGetDesktopWindow() && 1031 co_IntSendMessage( UserHMGetHandle(parent), WM_SETCURSOR, wParam, lParam)) 1032 return TRUE; 1033 } 1034 } 1035 return DefWndHandleSetCursor(Wnd, wParam, lParam); 1036 } 1037 1038 case WM_MOUSEACTIVATE: 1039 if (Wnd->style & WS_CHILD) 1040 { 1041 LONG Ret; 1042 HWND hwndParent; 1043 PWND pwndParent = IntGetParent(Wnd); 1044 hwndParent = pwndParent ? UserHMGetHandle(pwndParent) : NULL; 1045 if (hwndParent) Ret = co_IntSendMessage(hwndParent, WM_MOUSEACTIVATE, wParam, lParam); 1046 if (Ret) return (Ret); 1047 } 1048 return ( (HIWORD(lParam) == WM_LBUTTONDOWN && LOWORD(lParam) == HTCAPTION) ? MA_NOACTIVATE : MA_ACTIVATE ); 1049 1050 case WM_ACTIVATE: 1051 /* The default action in Windows is to set the keyboard focus to 1052 * the window, if it's being activated and not minimized */ 1053 if (LOWORD(wParam) != WA_INACTIVE && 1054 !(Wnd->style & WS_MINIMIZE)) 1055 { 1056 //ERR("WM_ACTIVATE %p\n",hWnd); 1057 co_UserSetFocus(Wnd); 1058 } 1059 break; 1060 1061 case WM_MOUSEWHEEL: 1062 if (Wnd->style & WS_CHILD) 1063 { 1064 HWND hwndParent; 1065 PWND pwndParent = IntGetParent(Wnd); 1066 hwndParent = pwndParent ? UserHMGetHandle(pwndParent) : NULL; 1067 return co_IntSendMessage( hwndParent, WM_MOUSEWHEEL, wParam, lParam); 1068 } 1069 break; 1070 1071 case WM_ERASEBKGND: 1072 case WM_ICONERASEBKGND: 1073 { 1074 RECT Rect; 1075 HBRUSH hBrush = Wnd->pcls->hbrBackground; 1076 if (!hBrush) return 0; 1077 if (hBrush <= (HBRUSH)COLOR_MENUBAR) 1078 { 1079 hBrush = IntGetSysColorBrush(HandleToUlong(hBrush)); 1080 } 1081 if (Wnd->pcls->style & CS_PARENTDC) 1082 { 1083 /* can't use GetClipBox with a parent DC or we fill the whole parent */ 1084 IntGetClientRect(Wnd, &Rect); 1085 GreDPtoLP((HDC)wParam, (LPPOINT)&Rect, 2); 1086 } 1087 else 1088 { 1089 GdiGetClipBox((HDC)wParam, &Rect); 1090 } 1091 FillRect((HDC)wParam, &Rect, hBrush); 1092 return (1); 1093 } 1094 1095 case WM_GETHOTKEY: 1096 //ERR("WM_GETHOTKEY\n"); 1097 return DefWndGetHotKey(Wnd); 1098 case WM_SETHOTKEY: 1099 //ERR("WM_SETHOTKEY\n"); 1100 return DefWndSetHotKey(Wnd, wParam); 1101 1102 case WM_NCHITTEST: 1103 { 1104 POINT Point; 1105 Point.x = GET_X_LPARAM(lParam); 1106 Point.y = GET_Y_LPARAM(lParam); 1107 return GetNCHitEx(Wnd, Point); 1108 } 1109 1110 case WM_PRINT: 1111 { 1112 DefWndPrint(Wnd, (HDC)wParam, lParam); 1113 return (0); 1114 } 1115 1116 case WM_SYSCOLORCHANGE: 1117 { 1118 /* force to redraw non-client area */ 1119 UserPaintCaption(Wnd, DC_NC); 1120 /* Use InvalidateRect to redraw client area, enable 1121 * erase to redraw all subcontrols otherwise send the 1122 * WM_SYSCOLORCHANGE to child windows/controls is required 1123 */ 1124 co_UserRedrawWindow( Wnd, NULL, NULL, RDW_ALLCHILDREN|RDW_INVALIDATE|RDW_ERASE); 1125 return (0); 1126 } 1127 1128 case WM_PAINTICON: 1129 case WM_PAINT: 1130 { 1131 PAINTSTRUCT Ps; 1132 HDC hDC; 1133 1134 /* If already in Paint and Client area is not empty just return. */ 1135 if (Wnd->state2 & WNDS2_STARTPAINT && !RECTL_bIsEmptyRect(&Wnd->rcClient)) 1136 { 1137 ERR("In Paint and Client area is not empty!\n"); 1138 return 0; 1139 } 1140 1141 hDC = IntBeginPaint(Wnd, &Ps); 1142 if (hDC) 1143 { 1144 if (((Wnd->style & WS_MINIMIZE) != 0) && (Wnd->pcls->spicn)) 1145 { 1146 RECT ClientRect; 1147 INT x, y; 1148 1149 ERR("Doing Paint and Client area is empty!\n"); 1150 IntGetClientRect(Wnd, &ClientRect); 1151 x = (ClientRect.right - ClientRect.left - UserGetSystemMetrics(SM_CXICON)) / 2; 1152 y = (ClientRect.bottom - ClientRect.top - UserGetSystemMetrics(SM_CYICON)) / 2; 1153 UserReferenceObject(Wnd->pcls->spicn); 1154 UserDrawIconEx(hDC, x, y, Wnd->pcls->spicn, 0, 0, 0, 0, DI_NORMAL | DI_COMPAT | DI_DEFAULTSIZE); 1155 UserDereferenceObject(Wnd->pcls->spicn); 1156 } 1157 1158 IntEndPaint(Wnd, &Ps); 1159 } 1160 return (0); 1161 } 1162 1163 case WM_SYNCPAINT: 1164 { 1165 HRGN hRgn; 1166 Wnd->state &= ~WNDS_SYNCPAINTPENDING; 1167 TRACE("WM_SYNCPAINT\n"); 1168 hRgn = NtGdiCreateRectRgn(0, 0, 0, 0); 1169 if (hRgn) 1170 { 1171 if (co_UserGetUpdateRgn(Wnd, hRgn, FALSE) != NULLREGION) 1172 { 1173 PREGION pRgn = REGION_LockRgn(hRgn); 1174 if (pRgn) REGION_UnlockRgn(pRgn); 1175 if (!wParam) 1176 wParam = (RDW_ERASENOW | RDW_ERASE | RDW_FRAME | RDW_ALLCHILDREN); 1177 co_UserRedrawWindow(Wnd, NULL, pRgn, wParam); 1178 } 1179 GreDeleteObject(hRgn); 1180 } 1181 return 0; 1182 } 1183 1184 case WM_SETREDRAW: 1185 if (wParam) 1186 { 1187 if (!(Wnd->style & WS_VISIBLE)) 1188 { 1189 IntSetStyle( Wnd, WS_VISIBLE, 0 ); 1190 Wnd->state |= WNDS_SENDNCPAINT; 1191 } 1192 } 1193 else 1194 { 1195 if (Wnd->style & WS_VISIBLE) 1196 { 1197 co_UserRedrawWindow( Wnd, NULL, NULL, RDW_ALLCHILDREN | RDW_VALIDATE ); 1198 IntSetStyle( Wnd, 0, WS_VISIBLE ); 1199 } 1200 } 1201 return 0; 1202 1203 case WM_WINDOWPOSCHANGING: 1204 { 1205 return (DefWndHandleWindowPosChanging(Wnd, (WINDOWPOS*)lParam)); 1206 } 1207 1208 case WM_WINDOWPOSCHANGED: 1209 { 1210 return (DefWndHandleWindowPosChanged(Wnd, (WINDOWPOS*)lParam)); 1211 } 1212 1213 case WM_NCCALCSIZE: 1214 { 1215 return NC_HandleNCCalcSize( Wnd, wParam, (RECTL *)lParam, FALSE ); 1216 } 1217 1218 case WM_NCACTIVATE: 1219 { 1220 return NC_HandleNCActivate( Wnd, wParam, lParam ); 1221 } 1222 1223 // 1224 // NC Paint mode. 1225 // 1226 case WM_NCPAINT: 1227 { 1228 HDC hDC = UserGetDCEx(Wnd, (HRGN)wParam, DCX_WINDOW | DCX_INTERSECTRGN | DCX_USESTYLE | DCX_KEEPCLIPRGN); 1229 Wnd->state |= WNDS_FORCEMENUDRAW; 1230 NC_DoNCPaint(Wnd, hDC, -1); 1231 Wnd->state &= ~WNDS_FORCEMENUDRAW; 1232 UserReleaseDC(Wnd, hDC, FALSE); 1233 return 0; 1234 } 1235 // 1236 // Draw Caption mode. 1237 // 1238 // wParam are DC_* flags. 1239 // 1240 case WM_NCUAHDRAWCAPTION: 1241 { 1242 HDC hDC = UserGetDCEx(Wnd, NULL, DCX_WINDOW|DCX_USESTYLE); 1243 TRACE("WM_NCUAHDRAWCAPTION: wParam DC_ flags %08x\n",wParam); 1244 UserDrawCaptionBar(Wnd, hDC, wParam | DC_FRAME); // Include DC_FRAME to comp for drawing glitch. 1245 UserReleaseDC(Wnd, hDC, FALSE); 1246 return 0; 1247 } 1248 // 1249 // Draw Frame mode. 1250 // 1251 // wParam is HDC, lParam are DC_ACTIVE and or DC_REDRAWHUNGWND. 1252 // 1253 case WM_NCUAHDRAWFRAME: 1254 { 1255 TRACE("WM_NCUAHDRAWFRAME: wParam hDC %p lParam DC_ flags %08x\n",wParam,lParam); 1256 NC_DoNCPaint(Wnd, (HDC)wParam, lParam|DC_NC); 1257 return 0; 1258 } 1259 1260 /* ReactOS only. */ 1261 case WM_CBT: 1262 { 1263 switch (wParam) 1264 { 1265 case HCBT_MOVESIZE: 1266 { 1267 RECTL rt; 1268 1269 if (lParam) 1270 { 1271 _SEH2_TRY 1272 { 1273 ProbeForRead((PVOID)lParam, 1274 sizeof(RECT), 1275 1); 1276 1277 RtlCopyMemory(&rt, 1278 (PVOID)lParam, 1279 sizeof(RECT)); 1280 } 1281 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) 1282 { 1283 lResult = 1; 1284 } 1285 _SEH2_END; 1286 } 1287 if (!lResult) 1288 lResult = co_HOOK_CallHooks(WH_CBT, HCBT_MOVESIZE, (WPARAM)Wnd->head.h, lParam ? (LPARAM)&rt : 0); 1289 } 1290 break; 1291 } 1292 break; 1293 } 1294 break; 1295 } 1296 return lResult; 1297 } 1298 1299 /* EOF */ 1300