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
12 DBG_DEFAULT_CHANNEL(UserDefwnd
);
14 INT WINAPI
DrawTextExWorker( HDC hdc
, LPWSTR str
, INT i_count
,
15 LPRECT rect
, UINT flags
, LPDRAWTEXTPARAMS dtp
);
17 INT WINAPI
DrawTextW( HDC hdc
, LPCWSTR str
, INT count
, LPRECT rect
, UINT flags
)
21 memset (&dtp
, 0, sizeof(dtp
));
22 dtp
.cbSize
= sizeof(dtp
);
23 if (flags
& DT_TABSTOP
)
25 dtp
.iTabLength
= (flags
>> 8) & 0xff;
28 return DrawTextExWorker(hdc
, (LPWSTR
)str
, count
, rect
, flags
, &dtp
);
33 DefWndControlColor(HDC hDC
, UINT ctlType
)
35 if (ctlType
== CTLCOLOR_SCROLLBAR
)
37 HBRUSH hb
= IntGetSysColorBrush(COLOR_SCROLLBAR
);
38 COLORREF bk
= IntGetSysColor(COLOR_3DHILIGHT
);
39 IntGdiSetTextColor(hDC
, IntGetSysColor(COLOR_3DFACE
));
40 IntGdiSetBkColor(hDC
, bk
);
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.
46 if ( bk
== IntGetSysColor(COLOR_WINDOW
))
49 NtGdiUnrealizeObject( hb
);
53 IntGdiSetTextColor(hDC
, IntGetSysColor(COLOR_WINDOWTEXT
));
55 if ((ctlType
== CTLCOLOR_EDIT
) || (ctlType
== CTLCOLOR_LISTBOX
))
57 IntGdiSetBkColor(hDC
, IntGetSysColor(COLOR_WINDOW
));
61 IntGdiSetBkColor(hDC
, IntGetSysColor(COLOR_3DFACE
));
62 return IntGetSysColorBrush(COLOR_3DFACE
);
65 return IntGetSysColorBrush(COLOR_WINDOW
);
69 DefWndHandleWindowPosChanging(PWND pWnd
, WINDOWPOS
* Pos
)
71 POINT maxTrack
, minTrack
;
72 LONG style
= pWnd
->style
;
74 if (Pos
->flags
& SWP_NOSIZE
) return 0;
75 if ((style
& WS_THICKFRAME
) || ((style
& (WS_POPUP
| WS_CHILD
)) == 0))
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
))
82 if (Pos
->cx
< minTrack
.x
) Pos
->cx
= minTrack
.x
;
83 if (Pos
->cy
< minTrack
.y
) Pos
->cy
= minTrack
.y
;
88 Pos
->cx
= max(Pos
->cx
, 0);
89 Pos
->cy
= max(Pos
->cy
, 0);
95 DefWndHandleWindowPosChanged(PWND pWnd
, WINDOWPOS
* Pos
)
98 LONG style
= pWnd
->style
;
100 IntGetClientRect(pWnd
, &Rect
);
101 IntMapWindowPoints(pWnd
, (style
& WS_CHILD
? IntGetParent(pWnd
) : NULL
), (LPPOINT
) &Rect
, 2);
103 if (!(Pos
->flags
& SWP_NOCLIENTMOVE
))
105 co_IntSendMessage(UserHMGetHandle(pWnd
), WM_MOVE
, 0, MAKELONG(Rect
.left
, Rect
.top
));
108 if (!(Pos
->flags
& SWP_NOCLIENTSIZE
) || (Pos
->flags
& SWP_STATECHANGED
))
110 if (style
& WS_MINIMIZE
) co_IntSendMessage(UserHMGetHandle(pWnd
), WM_SIZE
, SIZE_MINIMIZED
, 0 );
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
));
121 // Handle a WM_SYSCOMMAND message. Called from DefWindowProc().
124 DefWndHandleSysCommand(PWND pWnd
, WPARAM wParam
, LPARAM lParam
)
129 if (ISITHOOKED(WH_CBT
) || (pWnd
->head
.rpdesk
->pDeskInfo
->fsHooks
& HOOKID_TO_FLAG(WH_CBT
)))
132 lResult
= co_HOOK_CallHooks(WH_CBT
, HCBT_SYSCOMMAND
, wParam
, lParam
);
134 if (lResult
) return lResult
;
137 switch (wParam
& 0xfff0)
141 DefWndDoSizeMove(pWnd
, wParam
);
145 if (UserHMGetHandle(pWnd
) == UserGetActiveWindow())
146 IntShowOwnedPopups(pWnd
,FALSE
); // This is done in ShowWindow! Need to retest!
147 co_WinPosShowWindow( pWnd
, SW_MINIMIZE
);
151 if (((pWnd
->style
& WS_MINIMIZE
) != 0) && UserHMGetHandle(pWnd
) == UserGetActiveWindow())
152 IntShowOwnedPopups(pWnd
,TRUE
);
153 co_WinPosShowWindow( pWnd
, SW_MAXIMIZE
);
157 if (((pWnd
->style
& WS_MINIMIZE
) != 0) && UserHMGetHandle(pWnd
) == UserGetActiveWindow())
158 IntShowOwnedPopups(pWnd
,TRUE
);
159 co_WinPosShowWindow( pWnd
, SW_RESTORE
);
163 return co_IntSendMessage(UserHMGetHandle(pWnd
), WM_CLOSE
, 0, 0);
166 ERR("Screensaver Called!\n");
167 UserPostMessage(hwndSAS
, WM_LOGONNOTIFY
, LN_START_SCREENSAVE
, 0); // always lParam 0 == not Secure
172 USER_REFERENCE_ENTRY Ref
;
174 pWnd
= ValidateHwndNoErr((HWND
)lParam
);
177 if (pWnd
->spwndLastActive
)
179 pWnd
= pWnd
->spwndLastActive
;
181 UserRefObjectCo(pWnd
, &Ref
);
182 co_IntSetForegroundWindow(pWnd
);
183 UserDerefObjectCo(pWnd
);
184 if (pWnd
->style
& WS_MINIMIZE
)
186 UserPostMessage(UserHMGetHandle(pWnd
), WM_SYSCOMMAND
, SC_RESTORE
, 0);
195 Pt
.x
= (short)LOWORD(lParam
);
196 Pt
.y
= (short)HIWORD(lParam
);
197 MENU_TrackMouseMenuBar(pWnd
, wParam
& 0x000f, Pt
);
202 MENU_TrackKbdMenuBar(pWnd
, wParam
, (WCHAR
)lParam
);
207 // We do not support anything else here so we should return normal even when sending a hook.
211 return(Hook
? 1 : 0); // Don't call us again from user space.
215 co_IntFindChildWindowToOwner(PWND Root
, PWND Owner
)
218 PWND Child
, OwnerWnd
;
220 for(Child
= Root
->spwndChild
; Child
; Child
= Child
->spwndNext
)
222 OwnerWnd
= Child
->spwndOwner
;
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
)
232 if(OwnerWnd
== Owner
)
242 DefWndHandleSetCursor(PWND pWnd
, WPARAM wParam
, LPARAM lParam
)
244 PWND pwndPopUP
= NULL
;
245 WORD Msg
= HIWORD(lParam
);
247 /* Not for child windows. */
248 if (UserHMGetHandle(pWnd
) != (HWND
)wParam
)
253 switch((short)LOWORD(lParam
))
257 //// This is the real fix for CORE-6129! This was a "Code hole".
258 USER_REFERENCE_ENTRY Ref
;
260 if (Msg
== WM_LBUTTONDOWN
)
262 // Find a pop up window to bring active.
263 pwndPopUP
= co_IntFindChildWindowToOwner(UserGetDesktopWindow(), pWnd
);
266 // Not a child pop up from desktop.
267 if ( pwndPopUP
!= UserGetDesktopWindow()->spwndChild
)
269 // Get original active window.
270 PWND pwndOrigActive
= gpqForeground
->spwndActive
;
272 co_WinPosSetWindowPos(pWnd
, NULL
, 0, 0, 0, 0, SWP_NOMOVE
| SWP_NOSIZE
| SWP_NOACTIVATE
);
274 UserRefObjectCo(pwndPopUP
, &Ref
);
275 //UserSetActiveWindow(pwndPopUP);
276 co_IntSetForegroundWindow(pwndPopUP
); // HACK
277 UserDerefObjectCo(pwndPopUP
);
279 // If the change was made, break out.
280 if (pwndOrigActive
!= gpqForeground
->spwndActive
)
286 if (Msg
== WM_LBUTTONDOWN
|| Msg
== WM_MBUTTONDOWN
||
287 Msg
== WM_RBUTTONDOWN
|| Msg
== WM_XBUTTONDOWN
)
293 UserHMGetHandle(pwndPopUP
),
295 gspv
.dwForegroundFlashCount
,
296 (gpsi
->dtCaretBlink
>> 3)};
298 // Now shake that window!
299 IntFlashWindowEx(pwndPopUP
, &fwi
);
301 UserPostMessage(hwndSAS
, WM_LOGONNOTIFY
, LN_MESSAGE_BEEP
, 0);
308 if (pWnd
->pcls
->spcur
)
310 IntSystemSetCursor(pWnd
->pcls
->spcur
);
318 if (pWnd
->style
& WS_MAXIMIZE
)
322 IntSystemSetCursor(SYSTEMCUR(SIZEWE
));
329 if (pWnd
->style
& WS_MAXIMIZE
)
333 IntSystemSetCursor(SYSTEMCUR(SIZENS
));
340 if (pWnd
->style
& WS_MAXIMIZE
)
344 IntSystemSetCursor(SYSTEMCUR(SIZENWSE
));
351 if (pWnd
->style
& WS_MAXIMIZE
)
355 IntSystemSetCursor(SYSTEMCUR(SIZENESW
));
359 IntSystemSetCursor(SYSTEMCUR(ARROW
));
363 VOID FASTCALL
DefWndPrint( PWND pwnd
, HDC hdc
, ULONG uFlags
)
368 if ( (uFlags
& PRF_CHECKVISIBLE
) &&
369 !IntIsWindowVisible(pwnd
) )
373 * Unimplemented flags.
375 if ( (uFlags
& PRF_CHILDREN
) ||
376 (uFlags
& PRF_OWNED
) ||
377 (uFlags
& PRF_NONCLIENT
) )
379 FIXME("WM_PRINT message with unsupported flags\n");
385 if ( uFlags
& PRF_ERASEBKGND
)
386 co_IntSendMessage(UserHMGetHandle(pwnd
), WM_ERASEBKGND
, (WPARAM
)hdc
, 0);
391 if ( uFlags
& PRF_CLIENT
)
392 co_IntSendMessage(UserHMGetHandle(pwnd
), WM_PRINTCLIENT
, (WPARAM
)hdc
, uFlags
);
396 UserPaintCaption(PWND pWnd
, INT Flags
)
400 if ( (pWnd
->style
& WS_VISIBLE
) && ((pWnd
->style
& WS_CAPTION
) == WS_CAPTION
) )
402 if (pWnd
->state
& WNDS_HASCAPTION
&& pWnd
->head
.pti
->MessageQueue
== gpqForeground
)
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
410 if (gpsi
->dwSRVIFlags
& SRVINFO_APIHOOK
)
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
417 TRACE("UDCB Flags %08x\n");
418 co_IntSendMessage(UserHMGetHandle(pWnd
), WM_NCUAHDRAWCAPTION
, Flags
, 0);
422 HDC hDC
= UserGetDCEx(pWnd
, NULL
, DCX_WINDOW
|DCX_USESTYLE
);
423 UserDrawCaptionBar(pWnd
, hDC
, Flags
);
424 UserReleaseDC(pWnd
, hDC
, FALSE
);
428 // Support window tray
434 DefWndSetIcon(PWND pWnd
, WPARAM wParam
, LPARAM lParam
)
436 HICON hIcon
, hIconSmall
, hIconOld
;
438 if ( wParam
> ICON_SMALL2
)
440 EngSetLastError(ERROR_INVALID_PARAMETER
);
443 hIconSmall
= UserGetProp(pWnd
, gpsi
->atomIconSmProp
, TRUE
);
444 hIcon
= UserGetProp(pWnd
, gpsi
->atomIconProp
, TRUE
);
446 hIconOld
= wParam
== ICON_BIG
? hIcon
: hIconSmall
;
451 hIcon
= (HICON
)lParam
;
454 hIconSmall
= (HICON
)lParam
;
457 ERR("FIXME: Set ICON_SMALL2 support!\n");
462 UserSetProp(pWnd
, gpsi
->atomIconProp
, hIcon
, TRUE
);
463 UserSetProp(pWnd
, gpsi
->atomIconSmProp
, hIconSmall
, TRUE
);
465 if ((pWnd
->style
& WS_CAPTION
) == WS_CAPTION
)
466 UserPaintCaption(pWnd
, DC_ICON
);
468 return (LRESULT
)hIconOld
;
472 DefWndGetIcon(PWND pWnd
, WPARAM wParam
, LPARAM lParam
)
475 if ( wParam
> ICON_SMALL2
)
477 EngSetLastError(ERROR_INVALID_PARAMETER
);
483 hIconRet
= UserGetProp(pWnd
, gpsi
->atomIconProp
, TRUE
);
487 hIconRet
= UserGetProp(pWnd
, gpsi
->atomIconSmProp
, TRUE
);
492 return (LRESULT
)hIconRet
;
496 DefWndScreenshot(PWND pWnd
)
504 SETCLIPBDATA scd
= {FALSE
, FALSE
};
506 UserOpenClipboard(UserHMGetHandle(pWnd
));
507 UserEmptyClipboard();
509 hdc
= UserGetWindowDC(pWnd
);
510 IntGetWindowRect(pWnd
, &rect
);
511 w
= rect
.right
- rect
.left
;
512 h
= rect
.bottom
- rect
.top
;
514 hbitmap
= NtGdiCreateCompatibleBitmap(hdc
, w
, h
);
515 hdc2
= NtGdiCreateCompatibleDC(hdc
);
516 NtGdiSelectBitmap(hdc2
, hbitmap
);
518 NtGdiBitBlt(hdc2
, 0, 0, w
, h
, hdc
, 0, 0, SRCCOPY
, 0, 0);
520 UserSetClipboardData(CF_BITMAP
, hbitmap
, &scd
);
522 UserReleaseDC(pWnd
, hdc
, FALSE
);
523 UserReleaseDC(pWnd
, hdc2
, FALSE
);
525 UserCloseClipboard();
529 Win32k counterpart of User DefWindowProc
539 PTHREADINFO pti
= PsGetCurrentThreadWin32Thread();
541 USER_REFERENCE_ENTRY Ref
;
543 if (Msg
> WM_USER
) return 0;
547 case WM_GETTEXTLENGTH
:
552 if (Wnd
!= NULL
&& Wnd
->strName
.Length
!= 0)
554 buf
= Wnd
->strName
.Buffer
;
556 NT_SUCCESS(RtlUnicodeToMultiByteSize(&len
,
558 Wnd
->strName
.Length
)))
560 lResult
= (LRESULT
) (Wnd
->strName
.Length
/ sizeof(WCHAR
));
568 case WM_GETTEXT
: // FIXME: Handle Ansi
571 PWSTR outbuf
= (PWSTR
)lParam
;
573 if (Wnd
!= NULL
&& wParam
!= 0)
575 if (Wnd
->strName
.Buffer
!= NULL
)
576 buf
= Wnd
->strName
.Buffer
;
582 if (Wnd
->strName
.Length
!= 0)
584 lResult
= min(Wnd
->strName
.Length
/ sizeof(WCHAR
), wParam
- 1);
585 RtlCopyMemory(outbuf
,
587 lResult
* sizeof(WCHAR
));
588 outbuf
[lResult
] = L
'\0';
597 case WM_SETTEXT
: // FIXME: Handle Ansi
599 DefSetText(Wnd
, (PCWSTR
)lParam
);
601 if ((Wnd
->style
& WS_CAPTION
) == WS_CAPTION
)
602 UserPaintCaption(Wnd
, DC_TEXT
);
603 IntNotifyWinEvent(EVENT_OBJECT_NAMECHANGE
, Wnd
, OBJID_WINDOW
, CHILDID_SELF
, 0);
610 TRACE("hwnd %p WM_SYSCOMMAND %lx %lx\n", Wnd
->head
.h
, wParam
, lParam
);
611 lResult
= DefWndHandleSysCommand(Wnd
, wParam
, lParam
);
617 if ((Wnd
->style
& WS_VISIBLE
) && wParam
) break;
618 if (!(Wnd
->style
& WS_VISIBLE
) && !wParam
) break;
619 if (!Wnd
->spwndOwner
) break;
624 if (!(Wnd
->state
& WNDS_HIDDENPOPUP
)) break;
625 Wnd
->state
&= ~WNDS_HIDDENPOPUP
;
628 Wnd
->state
|= WNDS_HIDDENPOPUP
;
630 co_WinPosShowWindow(Wnd
, wParam
? SW_SHOWNOACTIVATE
: SW_HIDE
);
635 case WM_CLIENTSHUTDOWN
:
636 return IntClientShutdown(Wnd
, wParam
, lParam
);
639 if ( (Wnd
->style
& (WS_POPUP
|WS_CHILD
)) != WS_CHILD
&&
640 Wnd
!= co_GetDesktopWindow(Wnd
) )
642 if (!co_HOOK_CallHooks(WH_SHELL
, HSHELL_APPCOMMAND
, wParam
, lParam
))
643 co_IntShellHookNotify(HSHELL_APPCOMMAND
, wParam
, lParam
);
646 UserRefObjectCo(Wnd
->spwndParent
, &Ref
);
647 lResult
= co_IntSendMessage(UserHMGetHandle(Wnd
->spwndParent
), WM_APPCOMMAND
, wParam
, lParam
);
648 UserDerefObjectCo(Wnd
->spwndParent
);
654 HMENU hMenu
= UlongToHandle(Wnd
->IDMenu
);
655 PWND pwndActive
= MENU_IsMenuActive();
656 hi
.cbSize
= sizeof(HELPINFO
);
657 hi
.MousePos
= gpsi
->ptCursor
;
658 hi
.iContextType
= HELPINFO_MENUITEM
;
659 hi
.hItemHandle
= pwndActive
? UserHMGetHandle(pwndActive
) : UserHMGetHandle(Wnd
);
660 hi
.iCtrlId
= (Wnd
->style
& (WS_POPUP
|WS_CHILD
)) == WS_CHILD
? IntMenuItemFromPoint(Wnd
, hMenu
, hi
.MousePos
) : 0;
661 hi
.dwContextId
= IntGetWindowContextHelpId(Wnd
);
663 co_IntSendMessage( UserHMGetHandle(Wnd
), WM_HELP
, 0, (LPARAM
)&hi
);
669 return DefWndSetIcon(Wnd
, wParam
, lParam
);
674 return DefWndGetIcon(Wnd
, wParam
, lParam
);
679 PWND Parent
= IntGetParent(Wnd
);
680 co_IntSendMessage(UserHMGetHandle(Parent
), Msg
, wParam
, lParam
);
687 pti
->MessageQueue
->QF_flags
&= ~(QF_FMENUSTATUS
|QF_FMENUSTATUSBREAK
);
690 case WM_NCLBUTTONDOWN
:
691 return NC_HandleNCLButtonDown(Wnd
, wParam
, lParam
);
693 case WM_NCRBUTTONDOWN
:
694 return NC_HandleNCRButtonDown(Wnd
, wParam
, lParam
);
696 case WM_LBUTTONDBLCLK
:
697 return NC_HandleNCLButtonDblClk(Wnd
, HTCLIENT
, lParam
);
699 case WM_NCLBUTTONDBLCLK
:
700 return NC_HandleNCLButtonDblClk(Wnd
, wParam
, lParam
);
706 Pt
.x
= GET_X_LPARAM(lParam
);
707 Pt
.y
= GET_Y_LPARAM(lParam
);
708 IntClientToScreen(Wnd
, &Pt
);
709 lParam
= MAKELPARAM(Pt
.x
, Pt
.y
);
710 co_IntSendMessage(UserHMGetHandle(Wnd
), WM_CONTEXTMENU
, (WPARAM
)UserHMGetHandle(Wnd
), lParam
);
716 * FIXME : we must NOT send WM_CONTEXTMENU on a WM_NCRBUTTONUP (checked
717 * in Windows), but what _should_ we do? According to MSDN :
718 * "If it is appropriate to do so, the system sends the WM_SYSCOMMAND
719 * message to the window". When is it appropriate?
721 ERR("WM_NCRBUTTONUP\n");
726 if (HIWORD(wParam
) == XBUTTON1
|| HIWORD(wParam
) == XBUTTON2
)
728 co_IntSendMessage(UserHMGetHandle(Wnd
), WM_APPCOMMAND
, (WPARAM
)UserHMGetHandle(Wnd
),
729 MAKELPARAM(LOWORD(wParam
), FAPPCOMMAND_MOUSE
| HIWORD(wParam
)));
736 if (Wnd
->style
& WS_CHILD
)
738 co_IntSendMessage(UserHMGetHandle(IntGetParent(Wnd
)), Msg
, wParam
, lParam
);
748 Pt
.x
= GET_X_LPARAM(lParam
);
749 Pt
.y
= GET_Y_LPARAM(lParam
);
750 if (Style
& WS_CHILD
)
752 IntScreenToClient(IntGetParent(Wnd
), &Pt
);
755 HitCode
= GetNCHitEx(Wnd
, Pt
);
757 if (HitCode
== HTCAPTION
|| HitCode
== HTSYSMENU
)
762 if((SystemMenu
= IntGetSystemMenu(Wnd
, FALSE
)))
764 MENU_InitSysMenuPopup(SystemMenu
, Wnd
->style
, Wnd
->pcls
->style
, HitCode
);
766 if(HitCode
== HTCAPTION
)
767 Flags
= TPM_LEFTBUTTON
| TPM_RIGHTBUTTON
;
769 Flags
= TPM_LEFTBUTTON
;
771 IntTrackPopupMenuEx(SystemMenu
, Flags
|TPM_SYSTEM_MENU
, Pt
.x
, Pt
.y
, Wnd
, NULL
);
774 if (HitCode
== HTHSCROLL
|| HitCode
== HTVSCROLL
)
776 WARN("Scroll Menu Not Supported\n");
783 if (wParam
== VK_F10
)
785 pti
->MessageQueue
->QF_flags
|= QF_FF10STATUS
;
787 if (UserGetKeyState(VK_SHIFT
) & 0x8000)
789 co_IntSendMessage(UserHMGetHandle(Wnd
), WM_CONTEXTMENU
, (WPARAM
)UserHMGetHandle(Wnd
), MAKELPARAM(-1, -1));
796 if (HIWORD(lParam
) & KF_ALTDOWN
)
797 { /* Previous state, if the key was down before this message,
798 this is a cheap way to ignore autorepeat keys. */
799 if ( !(HIWORD(lParam
) & KF_REPEAT
) )
801 if ( ( wParam
== VK_MENU
||
802 wParam
== VK_LMENU
||
803 wParam
== VK_RMENU
) && !(pti
->MessageQueue
->QF_flags
& QF_FMENUSTATUS
)) //iMenuSysKey )
804 pti
->MessageQueue
->QF_flags
|= QF_FMENUSTATUS
; //iMenuSysKey = 1;
806 pti
->MessageQueue
->QF_flags
&= ~QF_FMENUSTATUS
; //iMenuSysKey = 0;
809 pti
->MessageQueue
->QF_flags
&= ~QF_FF10STATUS
; //iF10Key = 0;
811 if (wParam
== VK_F4
) /* Try to close the window */
813 PWND top
= UserGetAncestor(Wnd
, GA_ROOT
);
814 if (!(top
->style
& CS_NOCLOSE
))
815 UserPostMessage(UserHMGetHandle(top
), WM_SYSCOMMAND
, SC_CLOSE
, 0);
817 else if (wParam
== VK_SNAPSHOT
) // Alt-VK_SNAPSHOT?
820 while (IntGetParent(pwnd
) != NULL
)
822 pwnd
= IntGetParent(pwnd
);
824 ERR("DefWndScreenshot\n");
825 DefWndScreenshot(pwnd
);
827 else if ( wParam
== VK_ESCAPE
|| wParam
== VK_TAB
) // Alt-Tab/ESC Alt-Shift-Tab/ESC
830 HWND Active
= UserGetActiveWindow(); // Noticed MDI problem.
833 FIXME("WM_SYSKEYDOWN VK_ESCAPE no active\n");
836 wParamTmp
= UserGetKeyState(VK_SHIFT
) & 0x8000 ? SC_PREVWINDOW
: SC_NEXTWINDOW
;
837 co_IntSendMessage( Active
, WM_SYSCOMMAND
, wParamTmp
, wParam
);
840 else if( wParam
== VK_F10
)
842 if (UserGetKeyState(VK_SHIFT
) & 0x8000)
843 co_IntSendMessage( UserHMGetHandle(Wnd
), WM_CONTEXTMENU
, (WPARAM
)UserHMGetHandle(Wnd
), MAKELPARAM(-1, -1) );
844 pti
->MessageQueue
->QF_flags
|= QF_FF10STATUS
; //iF10Key = 1;
846 else if( wParam
== VK_ESCAPE
&& (UserGetKeyState(VK_SHIFT
) & 0x8000))
847 co_IntSendMessage( UserHMGetHandle(Wnd
), WM_SYSCOMMAND
, SC_KEYMENU
, ' ' );
854 /* Press and release F10 or ALT */
855 if (((wParam
== VK_MENU
|| wParam
== VK_LMENU
|| wParam
== VK_RMENU
)
856 && (pti
->MessageQueue
->QF_flags
& (QF_FMENUSTATUS
|QF_FMENUSTATUSBREAK
)) == QF_FMENUSTATUS
/*iMenuSysKey*/) ||
857 ((wParam
== VK_F10
) && pti
->MessageQueue
->QF_flags
& QF_FF10STATUS
/*iF10Key*/))
858 co_IntSendMessage( UserHMGetHandle(UserGetAncestor( Wnd
, GA_ROOT
)), WM_SYSCOMMAND
, SC_KEYMENU
, 0L );
859 pti
->MessageQueue
->QF_flags
&= ~(QF_FMENUSTATUS
|QF_FMENUSTATUSBREAK
|QF_FF10STATUS
); //iMenuSysKey = iF10Key = 0;
865 pti
->MessageQueue
->QF_flags
&= ~(QF_FMENUSTATUS
|QF_FMENUSTATUSBREAK
); //iMenuSysKey = 0;
866 if (wParam
== VK_RETURN
&& (Wnd
->style
& WS_MINIMIZE
) != 0)
868 UserPostMessage( UserHMGetHandle(Wnd
), WM_SYSCOMMAND
, SC_RESTORE
, 0L );
871 if ((HIWORD(lParam
) & KF_ALTDOWN
) && wParam
)
873 if (wParam
== VK_TAB
|| wParam
== VK_ESCAPE
) break;
874 if (wParam
== VK_SPACE
&& Wnd
->style
& WS_CHILD
)
875 co_IntSendMessage( UserHMGetHandle(IntGetParent(Wnd
)), Msg
, wParam
, lParam
);
877 co_IntSendMessage( UserHMGetHandle(Wnd
), WM_SYSCOMMAND
, SC_KEYMENU
, wParam
);
879 else /* check for Ctrl-Esc */
880 if (wParam
!= VK_ESCAPE
) UserPostMessage(hwndSAS
, WM_LOGONNOTIFY
, LN_MESSAGE_BEEP
, 0); //MessageBeep(0);
886 pti
->MessageQueue
->QF_flags
&= ~(QF_FMENUSTATUS
|QF_FMENUSTATUSBREAK
);
889 if (IntGetCaptureWindow() == UserHMGetHandle(Wnd
))
897 co_UserDestroyWindow(Wnd
);
900 case WM_CTLCOLORMSGBOX
:
901 case WM_CTLCOLOREDIT
:
902 case WM_CTLCOLORLISTBOX
:
905 case WM_CTLCOLORSTATIC
:
906 case WM_CTLCOLORSCROLLBAR
:
907 return (LRESULT
) DefWndControlColor((HDC
)wParam
, Msg
- WM_CTLCOLORMSGBOX
);
910 return (LRESULT
) DefWndControlColor((HDC
)wParam
, HIWORD(lParam
));
914 if (Wnd
->style
& WS_CHILD
)
916 /* with the exception of the border around a resizable wnd,
917 * give the parent first chance to set the cursor */
918 if (LOWORD(lParam
) < HTLEFT
|| LOWORD(lParam
) > HTBOTTOMRIGHT
)
920 PWND parent
= Wnd
->spwndParent
;//IntGetParent( Wnd );
921 if (parent
!= UserGetDesktopWindow() &&
922 co_IntSendMessage( UserHMGetHandle(parent
), WM_SETCURSOR
, wParam
, lParam
))
926 return DefWndHandleSetCursor(Wnd
, wParam
, lParam
);
929 case WM_MOUSEACTIVATE
:
930 if (Wnd
->style
& WS_CHILD
)
934 PWND pwndParent
= IntGetParent(Wnd
);
935 hwndParent
= pwndParent
? UserHMGetHandle(pwndParent
) : NULL
;
936 if (hwndParent
) Ret
= co_IntSendMessage(hwndParent
, WM_MOUSEACTIVATE
, wParam
, lParam
);
937 if (Ret
) return (Ret
);
939 return ( (HIWORD(lParam
) == WM_LBUTTONDOWN
&& LOWORD(lParam
) == HTCAPTION
) ? MA_NOACTIVATE
: MA_ACTIVATE
);
942 /* The default action in Windows is to set the keyboard focus to
943 * the window, if it's being activated and not minimized */
944 if (LOWORD(wParam
) != WA_INACTIVE
&&
945 !(Wnd
->style
& WS_MINIMIZE
))
947 //ERR("WM_ACTIVATE %p\n",hWnd);
948 co_UserSetFocus(Wnd
);
953 if (Wnd
->style
& WS_CHILD
)
956 PWND pwndParent
= IntGetParent(Wnd
);
957 hwndParent
= pwndParent
? UserHMGetHandle(pwndParent
) : NULL
;
958 return co_IntSendMessage( hwndParent
, WM_MOUSEWHEEL
, wParam
, lParam
);
963 case WM_ICONERASEBKGND
:
966 HBRUSH hBrush
= Wnd
->pcls
->hbrBackground
;
967 if (!hBrush
) return 0;
968 if (hBrush
<= (HBRUSH
)COLOR_MENUBAR
)
970 hBrush
= IntGetSysColorBrush(HandleToUlong(hBrush
));
972 if (Wnd
->pcls
->style
& CS_PARENTDC
)
974 /* can't use GetClipBox with a parent DC or we fill the whole parent */
975 IntGetClientRect(Wnd
, &Rect
);
976 GreDPtoLP((HDC
)wParam
, (LPPOINT
)&Rect
, 2);
980 GdiGetClipBox((HDC
)wParam
, &Rect
);
982 FillRect((HDC
)wParam
, &Rect
, hBrush
);
987 //ERR("WM_GETHOTKEY\n");
988 return DefWndGetHotKey(Wnd
);
990 //ERR("WM_SETHOTKEY\n");
991 return DefWndSetHotKey(Wnd
, wParam
);
996 Point
.x
= GET_X_LPARAM(lParam
);
997 Point
.y
= GET_Y_LPARAM(lParam
);
998 return GetNCHitEx(Wnd
, Point
);
1003 DefWndPrint(Wnd
, (HDC
)wParam
, lParam
);
1007 case WM_SYSCOLORCHANGE
:
1009 /* force to redraw non-client area */
1010 UserPaintCaption(Wnd
, DC_NC
);
1011 /* Use InvalidateRect to redraw client area, enable
1012 * erase to redraw all subcontrols otherwise send the
1013 * WM_SYSCOLORCHANGE to child windows/controls is required
1015 co_UserRedrawWindow( Wnd
, NULL
, NULL
, RDW_ALLCHILDREN
|RDW_INVALIDATE
|RDW_ERASE
);
1025 /* If already in Paint and Client area is not empty just return. */
1026 if (Wnd
->state2
& WNDS2_STARTPAINT
&& !RECTL_bIsEmptyRect(&Wnd
->rcClient
))
1028 ERR("In Paint and Client area is not empty!\n");
1032 hDC
= IntBeginPaint(Wnd
, &Ps
);
1035 if (((Wnd
->style
& WS_MINIMIZE
) != 0) && (Wnd
->pcls
->spicn
))
1040 ERR("Doing Paint and Client area is empty!\n");
1041 IntGetClientRect(Wnd
, &ClientRect
);
1042 x
= (ClientRect
.right
- ClientRect
.left
- UserGetSystemMetrics(SM_CXICON
)) / 2;
1043 y
= (ClientRect
.bottom
- ClientRect
.top
- UserGetSystemMetrics(SM_CYICON
)) / 2;
1044 UserReferenceObject(Wnd
->pcls
->spicn
);
1045 UserDrawIconEx(hDC
, x
, y
, Wnd
->pcls
->spicn
, 0, 0, 0, 0, DI_NORMAL
| DI_COMPAT
| DI_DEFAULTSIZE
);
1046 UserDereferenceObject(Wnd
->pcls
->spicn
);
1049 IntEndPaint(Wnd
, &Ps
);
1057 Wnd
->state
&= ~WNDS_SYNCPAINTPENDING
;
1058 TRACE("WM_SYNCPAINT\n");
1059 hRgn
= NtGdiCreateRectRgn(0, 0, 0, 0);
1062 if (co_UserGetUpdateRgn(Wnd
, hRgn
, FALSE
) != NULLREGION
)
1064 PREGION pRgn
= REGION_LockRgn(hRgn
);
1065 if (pRgn
) REGION_UnlockRgn(pRgn
);
1067 wParam
= (RDW_ERASENOW
| RDW_ERASE
| RDW_FRAME
| RDW_ALLCHILDREN
);
1068 co_UserRedrawWindow(Wnd
, NULL
, pRgn
, wParam
);
1070 GreDeleteObject(hRgn
);
1078 if (!(Wnd
->style
& WS_VISIBLE
))
1080 IntSetStyle( Wnd
, WS_VISIBLE
, 0 );
1081 Wnd
->state
|= WNDS_SENDNCPAINT
;
1086 if (Wnd
->style
& WS_VISIBLE
)
1088 co_UserRedrawWindow( Wnd
, NULL
, NULL
, RDW_ALLCHILDREN
| RDW_VALIDATE
);
1089 IntSetStyle( Wnd
, 0, WS_VISIBLE
);
1094 case WM_WINDOWPOSCHANGING
:
1096 return (DefWndHandleWindowPosChanging(Wnd
, (WINDOWPOS
*)lParam
));
1099 case WM_WINDOWPOSCHANGED
:
1101 return (DefWndHandleWindowPosChanged(Wnd
, (WINDOWPOS
*)lParam
));
1106 return NC_HandleNCCalcSize( Wnd
, wParam
, (RECTL
*)lParam
, FALSE
);
1111 return NC_HandleNCActivate( Wnd
, wParam
, lParam
);
1119 HDC hDC
= UserGetDCEx(Wnd
, (HRGN
)wParam
, DCX_WINDOW
| DCX_INTERSECTRGN
| DCX_USESTYLE
| DCX_KEEPCLIPRGN
);
1120 Wnd
->state
|= WNDS_FORCEMENUDRAW
;
1121 NC_DoNCPaint(Wnd
, hDC
, -1);
1122 Wnd
->state
&= ~WNDS_FORCEMENUDRAW
;
1123 UserReleaseDC(Wnd
, hDC
, FALSE
);
1127 // Draw Caption mode.
1129 // wParam are DC_* flags.
1131 case WM_NCUAHDRAWCAPTION
:
1133 HDC hDC
= UserGetDCEx(Wnd
, NULL
, DCX_WINDOW
|DCX_USESTYLE
);
1134 TRACE("WM_NCUAHDRAWCAPTION: wParam DC_ flags %08x\n",wParam
);
1135 UserDrawCaptionBar(Wnd
, hDC
, wParam
|DC_FRAME
); // Include DC_FRAME to comp for drawing glich.
1136 UserReleaseDC(Wnd
, hDC
, FALSE
);
1142 // wParam is HDC, lParam are DC_ACTIVE and or DC_REDRAWHUNGWND.
1144 case WM_NCUAHDRAWFRAME
:
1146 TRACE("WM_NCUAHDRAWFRAME: wParam hDC %p lParam DC_ flags %08x\n",wParam
,lParam
);
1147 NC_DoNCPaint(Wnd
, (HDC
)wParam
, lParam
|DC_NC
);
1164 ProbeForRead((PVOID
)lParam
,
1172 _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER
)
1179 lResult
= co_HOOK_CallHooks(WH_CBT
, HCBT_MOVESIZE
, (WPARAM
)Wnd
->head
.h
, lParam
? (LPARAM
)&rt
: 0);