diff --git a/reactos/dll/win32/user32/windows/nonclient.c b/reactos/dll/win32/user32/windows/nonclient.c index 8b27ed1d30b..903793a21f3 100644 --- a/reactos/dll/win32/user32/windows/nonclient.c +++ b/reactos/dll/win32/user32/windows/nonclient.c @@ -1116,7 +1116,9 @@ DrawCaptionTempW( UINT uFlags ) { - return NtUserDrawCaptionTemp(hWnd, hDC, rect, hFont, hIcon, str, uFlags); + UNICODE_STRING Text = {0}; + RtlInitUnicodeString(&Text, str); + return NtUserDrawCaptionTemp(hWnd, hDC, rect, hFont, hIcon, &Text, uFlags); } /* diff --git a/reactos/include/reactos/win32k/ntuser.h b/reactos/include/reactos/win32k/ntuser.h index e3f0a557495..1c86c67c0db 100644 --- a/reactos/include/reactos/win32k/ntuser.h +++ b/reactos/include/reactos/win32k/ntuser.h @@ -721,10 +721,10 @@ STDCALL NtUserDrawCaptionTemp( HWND hWnd, HDC hDC, - const RECT *rect, + LPCRECT lpRc, HFONT hFont, HICON hIcon, - LPCWSTR str, + const PUNICODE_STRING str, UINT uFlags); BOOL diff --git a/reactos/subsystems/win32/win32k/ntuser/ntstubs.c b/reactos/subsystems/win32/win32k/ntuser/ntstubs.c index dd043db2c7c..cdaef37176e 100644 --- a/reactos/subsystems/win32/win32k/ntuser/ntstubs.c +++ b/reactos/subsystems/win32/win32k/ntuser/ntstubs.c @@ -180,21 +180,6 @@ NtUserDrawAnimatedRects( return 0; } -BOOL -STDCALL -NtUserDrawCaptionTemp( - HWND hWnd, - HDC hDC, - const RECT *rect, - HFONT hFont, - HICON hIcon, - LPCWSTR str, - UINT uFlags) -{ - UNIMPLEMENTED - return FALSE; -} - BOOL STDCALL NtUserEnumDisplayDevices ( diff --git a/reactos/subsystems/win32/win32k/ntuser/painting.c b/reactos/subsystems/win32/win32k/ntuser/painting.c index 1f89e95d5e7..1b43e12d3cb 100644 --- a/reactos/subsystems/win32/win32k/ntuser/painting.c +++ b/reactos/subsystems/win32/win32k/ntuser/painting.c @@ -1492,6 +1492,9 @@ BOOL UserDrawCaption( PWINDOW_OBJECT pWnd, HDC hDc, LPCRECT lpRc, + HFONT hFont, + HICON hIcon, + const PUNICODE_STRING str, UINT uFlags) { BOOL Ret = FALSE; @@ -1504,7 +1507,7 @@ BOOL UserDrawCaption( LONG ButtonWidth, IconWidth; BOOL HasIcon; - ASSERT(pWnd != NULL); + //ASSERT(pWnd != NULL); hMemBmp = NtGdiCreateCompatibleBitmap(hDc, lpRc->right - lpRc->left, @@ -1533,9 +1536,16 @@ BOOL UserDrawCaption( Height = UserGetSystemMetrics(SM_CYCAPTION) - 1; VCenter = (lpRc->bottom - lpRc->top) / 2; Padding = VCenter - (Height / 2); - HasIcon = (uFlags & DC_ICON) && (pWnd->Style & WS_SYSMENU) - && !(uFlags & DC_SMALLCAP) && !(pWnd->ExStyle & WS_EX_DLGMODALFRAME) - && !(pWnd->ExStyle & WS_EX_TOOLWINDOW); + + if ((!hIcon) && (pWnd != NULL)) + { + HasIcon = (uFlags & DC_ICON) && (pWnd->Style & WS_SYSMENU) + && !(uFlags & DC_SMALLCAP) && !(pWnd->ExStyle & WS_EX_DLGMODALFRAME) + && !(pWnd->ExStyle & WS_EX_TOOLWINDOW); + } + else + HasIcon = (BOOL) hIcon; + IconWidth = UserGetSystemMetrics(SM_CXSIZE) + Padding; r.left = Padding; @@ -1607,33 +1617,36 @@ BOOL UserDrawCaption( COLORREF Colors[2]; PDC pMemDc; - if(pWnd->Style & WS_SYSMENU) - { - r.right -= 3 + ButtonWidth; - if(!(uFlags & DC_SMALLCAP)) - { - if(pWnd->Style & (WS_MAXIMIZEBOX | WS_MINIMIZEBOX)) - r.right -= 2 + 2 * ButtonWidth; - else r.right -= 2; - r.right -= 2; - } - - //Draw buttons background - if(!NtGdiSelectObject(hMemDc, - IntGetSysColorBrush(uFlags & DC_ACTIVE ? - COLOR_GRADIENTACTIVECAPTION:COLOR_GRADIENTINACTIVECAPTION))) - { - DPRINT1("%s: NtGdiSelectObject() failed!\n", __FUNCTION__); - goto cleanup; - } + if (pWnd != NULL) + { + if(pWnd->Style & WS_SYSMENU) + { + r.right -= 3 + ButtonWidth; + if(!(uFlags & DC_SMALLCAP)) + { + if(pWnd->Style & (WS_MAXIMIZEBOX | WS_MINIMIZEBOX)) + r.right -= 2 + 2 * ButtonWidth; + else r.right -= 2; + r.right -= 2; + } + + //Draw buttons background + if(!NtGdiSelectObject(hMemDc, + IntGetSysColorBrush(uFlags & DC_ACTIVE ? + COLOR_GRADIENTACTIVECAPTION:COLOR_GRADIENTINACTIVECAPTION))) + { + DPRINT1("%s: NtGdiSelectObject() failed!\n", __FUNCTION__); + goto cleanup; + } - NtGdiPatBlt(hMemDc, - r.right, - 0, - lpRc->right - lpRc->left - r.right, - lpRc->bottom - lpRc->top, - PATCOPY); - } + NtGdiPatBlt(hMemDc, + r.right, + 0, + lpRc->right - lpRc->left - r.right, + lpRc->bottom - lpRc->top, + PATCOPY); + } + } Colors[0] = IntGetSysColor((uFlags & DC_ACTIVE) ? COLOR_ACTIVECAPTION : COLOR_INACTIVECAPTION); @@ -1676,7 +1689,9 @@ BOOL UserDrawCaption( { r.top ++; r.left -= --IconWidth; - UserDrawSysMenuButton(pWnd, hMemDc, &r, FALSE); + /* FIXME: Draw the Icon when pWnd == NULL but hIcon is valid */ + if (pWnd != NULL) + UserDrawSysMenuButton(pWnd, hMemDc, &r, FALSE); r.left += IconWidth; r.top --; } @@ -1686,7 +1701,7 @@ BOOL UserDrawCaption( r.bottom = r.top + Height; - if((uFlags & DC_TEXT) && pWnd->WindowName.Length) + if((uFlags & DC_TEXT)) { if(!(uFlags & DC_GRADIENT)) { @@ -1709,7 +1724,11 @@ BOOL UserDrawCaption( } } - UserDrawCaptionText(hMemDc, &pWnd->WindowName, &r, uFlags); + /* FIXME: hFont isn't handled */ + if (str) + UserDrawCaptionText(hMemDc, str, &r, uFlags); + else if (pWnd != NULL) + UserDrawCaptionText(hMemDc, &pWnd->WindowName, &r, uFlags); } if(!NtGdiBitBlt(hDc, lpRc->left, lpRc->top, @@ -1732,30 +1751,50 @@ cleanup: } -BOOL -STDCALL -NtUserDrawCaption(HWND hWnd, - HDC hDc, +BOOL +STDCALL +NtUserDrawCaptionTemp( + HWND hWnd, + HDC hDC, LPCRECT lpRc, + HFONT hFont, + HICON hIcon, + const PUNICODE_STRING str, UINT uFlags) { - PWINDOW_OBJECT pWnd; + PWINDOW_OBJECT pWnd = NULL; RECT SafeRect; + UNICODE_STRING SafeStr = {0}; BOOL Ret = FALSE; UserEnterExclusive(); - if(!(pWnd = UserGetWindowObject(hWnd))) + if (hWnd != NULL) { - UserLeave(); - return FALSE; + if(!(pWnd = UserGetWindowObject(hWnd))) + { + UserLeave(); + return FALSE; + } } - + _SEH_TRY { ProbeForRead(lpRc, sizeof(RECT), sizeof(ULONG)); RtlCopyMemory(&SafeRect, lpRc, sizeof(RECT)); - Ret = UserDrawCaption(pWnd, hDc, &SafeRect, uFlags); + if (str != NULL) + { + SafeStr = ProbeForReadUnicodeString(str); + if (SafeStr.Length != 0) + { + ProbeForRead(SafeStr.Buffer, + SafeStr.Length, + sizeof(WCHAR)); + } + Ret = UserDrawCaption(pWnd, hDC, &SafeRect, hFont, hIcon, &SafeStr, uFlags); + } + else + Ret = UserDrawCaption(pWnd, hDC, &SafeRect, hFont, hIcon, NULL, uFlags); } _SEH_HANDLE { @@ -1767,4 +1806,14 @@ NtUserDrawCaption(HWND hWnd, return Ret; } +BOOL +STDCALL +NtUserDrawCaption(HWND hWnd, + HDC hDC, + LPCRECT lpRc, + UINT uFlags) +{ + return NtUserDrawCaptionTemp(hWnd, hDC, lpRc, 0, 0, NULL, uFlags); +} + /* EOF */