ReactOS 0.4.15-dev-7889-g76290a6
nonclient.c File Reference
#include "uxthemep.h"
Include dependency graph for nonclient.c:

Go to the source code of this file.

Macros

#define NC_PREVIEW_MSGBOX_HALF_WIDTH   75
 
#define NC_PREVIEW_MSGBOX_OFFSET_X   -29
 
#define NC_PREVIEW_MSGBOX_OFFSET_Y   71
 

Functions

static BOOL IsWindowActive (HWND hWnd, DWORD ExStyle)
 
BOOL IsScrollBarVisible (HWND hWnd, INT hBar)
 
static BOOL UserHasWindowEdge (DWORD Style, DWORD ExStyle)
 
static HICON UserGetWindowIcon (PDRAW_CONTEXT pcontext)
 
HRESULT WINAPI ThemeDrawCaptionText (PDRAW_CONTEXT pcontext, RECT *pRect, int iPartId, int iStateId)
 
void ThemeInitDrawContext (PDRAW_CONTEXT pcontext, HWND hWnd, HRGN hRgn)
 
void ThemeCleanupDrawContext (PDRAW_CONTEXT pcontext)
 
static void ThemeStartBufferedPaint (PDRAW_CONTEXT pcontext, int cx, int cy)
 
static void ThemeEndBufferedPaint (PDRAW_CONTEXT pcontext, int x, int y, int cx, int cy)
 
static void ThemeCalculateCaptionButtonsPosEx (WINDOWINFO *wi, HWND hWnd, HTHEME htheme, INT buttonHeight)
 
void ThemeCalculateCaptionButtonsPos (HWND hWnd, HTHEME htheme)
 
static void ThemeDrawCaptionButton (PDRAW_CONTEXT pcontext, RECT *prcCurrent, CAPTIONBUTTON buttonId, INT iStateId)
 
static DWORD ThemeGetButtonState (DWORD htCurrect, DWORD htHot, DWORD htDown, BOOL Active)
 
static void ThemeDrawCaptionButtons (PDRAW_CONTEXT pcontext, DWORD htHot, DWORD htDown)
 
static void ThemeDrawCaption (PDRAW_CONTEXT pcontext, RECT *prcCurrent)
 
static void ThemeDrawBorders (PDRAW_CONTEXT pcontext, RECT *prcCurrent)
 
static void DrawClassicFrame (PDRAW_CONTEXT context, RECT *prcCurrent)
 
static void ThemeDrawMenuBar (PDRAW_CONTEXT pcontext, RECT *prcCurrent)
 
static void ThemeDrawScrollBarsGrip (PDRAW_CONTEXT pcontext, RECT *prcCurrent)
 
static void ThemePaintWindow (PDRAW_CONTEXT pcontext, RECT *prcCurrent, BOOL bDoDoubleBuffering)
 
static LRESULT ThemeHandleNCPaint (HWND hWnd, HRGN hRgn)
 
static LRESULT ThemeHandleNcMouseMove (HWND hWnd, DWORD ht, POINT *pt)
 
static LRESULT ThemeHandleNcMouseLeave (HWND hWnd)
 
static VOID ThemeHandleButton (HWND hWnd, WPARAM wParam)
 
static LRESULT DefWndNCHitTest (HWND hWnd, POINT Point)
 
LRESULT CALLBACK ThemeWndProc (HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, WNDPROC DefWndProc)
 
static void DrawWindowForNCPreview (_In_ HDC hDC, _In_ PDRAW_CONTEXT pcontext, _In_ INT left, _In_ INT top, _In_ INT right, _In_ INT bottom, _In_ BOOL drawClientAreaColor, _Out_opt_ LPRECT prcClient)
 
VOID SetWindowResourceText (_In_ HWND hwnd, _In_ UINT uID)
 
HRESULT WINAPI DrawNCPreview (HDC hDC, DWORD DNCP_Flag, LPRECT prcPreview, LPCWSTR pszThemeFileName, LPCWSTR pszColorName, LPCWSTR pszSizeName, PNONCLIENTMETRICSW pncMetrics, COLORREF *lpaRgbValues)
 

Macro Definition Documentation

◆ NC_PREVIEW_MSGBOX_HALF_WIDTH

#define NC_PREVIEW_MSGBOX_HALF_WIDTH   75

Definition at line 11 of file nonclient.c.

◆ NC_PREVIEW_MSGBOX_OFFSET_X

#define NC_PREVIEW_MSGBOX_OFFSET_X   -29

Definition at line 12 of file nonclient.c.

◆ NC_PREVIEW_MSGBOX_OFFSET_Y

#define NC_PREVIEW_MSGBOX_OFFSET_Y   71

Definition at line 13 of file nonclient.c.

Function Documentation

◆ DefWndNCHitTest()

static LRESULT DefWndNCHitTest ( HWND  hWnd,
POINT  Point 
)
static

Definition at line 800 of file nonclient.c.

801{
802 RECT WindowRect;
803 POINT ClientPoint;
804 WINDOWINFO wi;
805
806 wi.cbSize = sizeof(wi);
807 GetWindowInfo(hWnd, &wi);
808
809 if (!PtInRect(&wi.rcWindow, Point))
810 {
811 return HTNOWHERE;
812 }
813 WindowRect = wi.rcWindow;
814
816 {
817 LONG XSize, YSize;
818
819 InflateRect(&WindowRect, -(int)wi.cxWindowBorders, -(int)wi.cyWindowBorders);
822 if (!PtInRect(&WindowRect, Point))
823 {
824 BOOL ThickFrame;
825
826 ThickFrame = (wi.dwStyle & WS_THICKFRAME);
827 if (Point.y < WindowRect.top)
828 {
829 if (wi.dwStyle & WS_MINIMIZE)
830 return HTCAPTION;
831 if (!ThickFrame)
832 return HTBORDER;
833 if (Point.x < (WindowRect.left + XSize))
834 return HTTOPLEFT;
835 if (Point.x >= (WindowRect.right - XSize))
836 return HTTOPRIGHT;
837 return HTTOP;
838 }
839 if (Point.y >= WindowRect.bottom)
840 {
841 if (wi.dwStyle & WS_MINIMIZE)
842 return HTCAPTION;
843 if (!ThickFrame)
844 return HTBORDER;
845 if (Point.x < (WindowRect.left + XSize))
846 return HTBOTTOMLEFT;
847 if (Point.x >= (WindowRect.right - XSize))
848 return HTBOTTOMRIGHT;
849 return HTBOTTOM;
850 }
851 if (Point.x < WindowRect.left)
852 {
853 if (wi.dwStyle & WS_MINIMIZE)
854 return HTCAPTION;
855 if (!ThickFrame)
856 return HTBORDER;
857 if (Point.y < (WindowRect.top + YSize))
858 return HTTOPLEFT;
859 if (Point.y >= (WindowRect.bottom - YSize))
860 return HTBOTTOMLEFT;
861 return HTLEFT;
862 }
863 if (Point.x >= WindowRect.right)
864 {
865 if (wi.dwStyle & WS_MINIMIZE)
866 return HTCAPTION;
867 if (!ThickFrame)
868 return HTBORDER;
869 if (Point.y < (WindowRect.top + YSize))
870 return HTTOPRIGHT;
871 if (Point.y >= (WindowRect.bottom - YSize))
872 return HTBOTTOMRIGHT;
873 return HTRIGHT;
874 }
875 }
876 }
877 else
878 {
882 if (!PtInRect(&WindowRect, Point))
883 return HTBORDER;
884 }
885
886 if ((wi.dwStyle & WS_CAPTION) == WS_CAPTION)
887 {
889 WindowRect.top += GetSystemMetrics(SM_CYSMCAPTION);
890 else
891 WindowRect.top += GetSystemMetrics(SM_CYCAPTION);
892
893 if (!PtInRect(&WindowRect, Point))
894 {
895 if (wi.dwStyle & WS_SYSMENU)
896 {
897 PWND_DATA pwndData = ThemeGetWndData(hWnd);
898
899 if (!(wi.dwExStyle & WS_EX_TOOLWINDOW))
900 {
901 // if (!(wi.dwExStyle & WS_EX_DLGMODALFRAME))
902 // FIXME: The real test should check whether there is
903 // an icon for the system window, and if so, do the
904 // rect.left increase.
905 // See win32ss/user/user32/windows/nonclient.c!DefWndNCHitTest
906 // and win32ss/user/ntuser/nonclient.c!GetNCHitEx which does
907 // the test better.
908 WindowRect.left += GetSystemMetrics(SM_CXSMICON);
909 }
910
911 if (pwndData)
912 {
913 POINT pt = {Point.x - wi.rcWindow.left, Point.y - wi.rcWindow.top};
914 if (PtInRect(&pwndData->rcCaptionButtons[CLOSEBUTTON], pt))
915 return HTCLOSE;
916 if (PtInRect(&pwndData->rcCaptionButtons[MAXBUTTON], pt))
917 return HTMAXBUTTON;
918 if (PtInRect(&pwndData->rcCaptionButtons[MINBUTTON], pt))
919 return HTMINBUTTON;
920 }
921 }
922 if (Point.x < WindowRect.left)
923 return HTSYSMENU;
924 return HTCAPTION;
925 }
926 }
927
928 if (!(wi.dwStyle & WS_MINIMIZE))
929 {
930 HMENU menu;
931
932 ClientPoint = Point;
933 ScreenToClient(hWnd, &ClientPoint);
935
936 if (PtInRect(&wi.rcClient, ClientPoint))
937 {
938 return HTCLIENT;
939 }
940
941 if ((menu = GetMenu(hWnd)) && !(wi.dwStyle & WS_CHILD))
942 {
943 if (Point.x > 0 && Point.x < WindowRect.right && ClientPoint.y < 0)
944 return HTMENU;
945 }
946
948 {
949 InflateRect(&WindowRect, -2 * GetSystemMetrics(SM_CXBORDER),
951 }
952
953 if ((wi.dwStyle & WS_VSCROLL) && (wi.dwStyle & WS_HSCROLL) &&
954 (WindowRect.bottom - WindowRect.top) > GetSystemMetrics(SM_CYHSCROLL))
955 {
956 RECT ParentRect, TempRect = WindowRect, TempRect2 = WindowRect;
958
960 if ((wi.dwExStyle & WS_EX_LEFTSCROLLBAR) != 0)
961 TempRect.right = TempRect.left + GetSystemMetrics(SM_CXVSCROLL);
962 else
963 TempRect.left = TempRect.right - GetSystemMetrics(SM_CXVSCROLL);
964 if (PtInRect(&TempRect, Point))
965 return HTVSCROLL;
966
967 TempRect2.top = TempRect2.bottom - GetSystemMetrics(SM_CYHSCROLL);
968 if ((wi.dwExStyle & WS_EX_LEFTSCROLLBAR) != 0)
969 TempRect2.left += GetSystemMetrics(SM_CXVSCROLL);
970 else
971 TempRect2.right -= GetSystemMetrics(SM_CXVSCROLL);
972 if (PtInRect(&TempRect2, Point))
973 return HTHSCROLL;
974
975 TempRect.top = TempRect2.top;
976 TempRect.bottom = TempRect2.bottom;
977 if (Parent)
978 GetClientRect(Parent, &ParentRect);
979 if (PtInRect(&TempRect, Point) && HASSIZEGRIP(wi.dwStyle, wi.dwExStyle,
980 GetWindowLongW(Parent, GWL_STYLE), wi.rcWindow, ParentRect))
981 {
982 if ((wi.dwExStyle & WS_EX_LEFTSCROLLBAR) != 0)
983 return HTBOTTOMLEFT;
984 else
985 return HTBOTTOMRIGHT;
986 }
987 }
988 else
989 {
990 if (wi.dwStyle & WS_VSCROLL)
991 {
992 RECT TempRect = WindowRect;
993
994 if ((wi.dwExStyle & WS_EX_LEFTSCROLLBAR) != 0)
995 TempRect.right = TempRect.left + GetSystemMetrics(SM_CXVSCROLL);
996 else
997 TempRect.left = TempRect.right - GetSystemMetrics(SM_CXVSCROLL);
998 if (PtInRect(&TempRect, Point))
999 return HTVSCROLL;
1000 }
1001 else if (wi.dwStyle & WS_HSCROLL)
1002 {
1003 RECT TempRect = WindowRect;
1004 TempRect.top = TempRect.bottom - GetSystemMetrics(SM_CYHSCROLL);
1005 if (PtInRect(&TempRect, Point))
1006 return HTHSCROLL;
1007 }
1008 }
1009 }
1010
1011 return HTNOWHERE;
1012}
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn UINT32 *TableIdx UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER void *Data ACPI_OBJECT_HANDLER void **Data ACPI_STRING ACPI_OBJECT_LIST ACPI_BUFFER *ReturnObjectBuffer ACPI_DEVICE_INFO **ReturnBuffer ACPI_HANDLE Parent
Definition: acpixf.h:732
HWND hWnd
Definition: settings.c:17
static BOOL UserHasWindowEdge(DWORD Style, DWORD ExStyle)
Definition: nonclient.c:46
#define pt(x, y)
Definition: drawing.c:79
unsigned int BOOL
Definition: ntddk_ex.h:94
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:63
#define WS_CHILD
Definition: pedump.c:617
#define WS_CAPTION
Definition: pedump.c:624
#define WS_SYSMENU
Definition: pedump.c:629
#define WS_VSCROLL
Definition: pedump.c:627
#define WS_MINIMIZE
Definition: pedump.c:622
long LONG
Definition: pedump.c:60
#define WS_HSCROLL
Definition: pedump.c:628
#define WS_THICKFRAME
Definition: pedump.c:630
RECT rcCaptionButtons[4]
Definition: uxthemep.h:170
long y
Definition: polytest.cpp:48
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
RECT rcClient
Definition: winuser.h:3768
DWORD cbSize
Definition: winuser.h:3766
DWORD dwExStyle
Definition: winuser.h:3770
DWORD dwStyle
Definition: winuser.h:3769
UINT cxWindowBorders
Definition: winuser.h:3772
UINT cyWindowBorders
Definition: winuser.h:3773
RECT rcWindow
Definition: winuser.h:3767
PWND_DATA ThemeGetWndData(HWND hWnd)
Definition: themehooks.c:17
#define HASSIZEGRIP(Style, ExStyle, ParentStyle, WindowRect, ParentClientRect)
Definition: uxthemep.h:232
@ CLOSEBUTTON
Definition: uxthemep.h:208
@ MAXBUTTON
Definition: uxthemep.h:209
@ MINBUTTON
Definition: uxthemep.h:210
#define HTTOPRIGHT
Definition: winuser.h:2492
#define HTCLOSE
Definition: winuser.h:2499
#define WS_EX_STATICEDGE
Definition: winuser.h:403
#define HTCAPTION
Definition: winuser.h:2476
#define HTTOPLEFT
Definition: winuser.h:2491
#define SM_CYSIZE
Definition: winuser.h:992
BOOL WINAPI GetWindowInfo(_In_ HWND, _Inout_ PWINDOWINFO)
#define SM_CXVSCROLL
Definition: winuser.h:961
#define HTBOTTOM
Definition: winuser.h:2493
#define HTBORDER
Definition: winuser.h:2497
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
#define HTVSCROLL
Definition: winuser.h:2482
#define HTHSCROLL
Definition: winuser.h:2481
#define WS_EX_TOOLWINDOW
Definition: winuser.h:404
#define HTMAXBUTTON
Definition: winuser.h:2484
#define SM_CXSIZE
Definition: winuser.h:991
#define SM_CYHSCROLL
Definition: winuser.h:962
#define HTMENU
Definition: winuser.h:2480
BOOL WINAPI PtInRect(_In_ LPCRECT, _In_ POINT)
#define SM_CYBORDER
Definition: winuser.h:965
#define SM_CXSMICON
Definition: winuser.h:1012
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define SM_CXBORDER
Definition: winuser.h:964
#define HTRIGHT
Definition: winuser.h:2489
#define HTCLIENT
Definition: winuser.h:2475
#define HTBOTTOMRIGHT
Definition: winuser.h:2495
#define HTNOWHERE
Definition: winuser.h:2474
HWND WINAPI GetParent(_In_ HWND)
#define HTBOTTOMLEFT
Definition: winuser.h:2494
#define HTTOP
Definition: winuser.h:2490
#define SM_CYSMCAPTION
Definition: winuser.h:1014
#define WS_EX_CLIENTEDGE
Definition: winuser.h:384
#define WS_EX_LEFTSCROLLBAR
Definition: winuser.h:392
#define HTMINBUTTON
Definition: winuser.h:2483
#define HTSYSMENU
Definition: winuser.h:2477
#define HTLEFT
Definition: winuser.h:2487
BOOL WINAPI InflateRect(_Inout_ LPRECT, _In_ int, _In_ int)
#define GWL_STYLE
Definition: winuser.h:852
#define SM_CYCAPTION
Definition: winuser.h:963
int WINAPI GetSystemMetrics(_In_ int)
HMENU WINAPI GetMenu(_In_ HWND)
BOOL WINAPI ScreenToClient(_In_ HWND, _Inout_ LPPOINT)

Referenced by ThemeWndProc().

◆ DrawClassicFrame()

static void DrawClassicFrame ( PDRAW_CONTEXT  context,
RECT prcCurrent 
)
static

Definition at line 460 of file nonclient.c.

461{
462 /* Draw outer edge */
463 if (UserHasWindowEdge(context->wi.dwStyle, context->wi.dwExStyle))
464 {
465 DrawEdge(context->hDC, prcCurrent, EDGE_RAISED, BF_RECT | BF_ADJUST);
466 }
467 else if (context->wi.dwExStyle & WS_EX_STATICEDGE)
468 {
470 }
471
472 /* Firstly the "thick" frame */
473 if ((context->wi.dwStyle & WS_THICKFRAME) && !(context->wi.dwStyle & WS_MINIMIZE))
474 {
475 INT Width =
478 INT Height =
481
484
485 /* Draw frame */
486 PatBlt(context->hDC, prcCurrent->left, prcCurrent->top,
487 prcCurrent->right - prcCurrent->left, Height, PATCOPY);
488 PatBlt(context->hDC, prcCurrent->left, prcCurrent->top,
489 Width, prcCurrent->bottom - prcCurrent->top, PATCOPY);
490 PatBlt(context->hDC, prcCurrent->left, prcCurrent->bottom - 1,
491 prcCurrent->right - prcCurrent->left, -Height, PATCOPY);
492 PatBlt(context->hDC, prcCurrent->right - 1, prcCurrent->top,
493 -Width, prcCurrent->bottom - prcCurrent->top, PATCOPY);
494
495 InflateRect(prcCurrent, -Width, -Height);
496 }
497
498 /* Now the other bit of the frame */
499 if (context->wi.dwStyle & (WS_DLGFRAME | WS_BORDER) || (context->wi.dwExStyle & WS_EX_DLGMODALFRAME))
500 {
503
506 (context->wi.dwExStyle & WS_EX_STATICEDGE) ? COLOR_WINDOWFRAME :
507 (context->wi.dwStyle & (WS_DLGFRAME | WS_THICKFRAME)) ? COLOR_3DFACE :
509
510 /* Draw frame */
511 PatBlt(context->hDC, prcCurrent->left, prcCurrent->top,
512 prcCurrent->right - prcCurrent->left, Height, PATCOPY);
513 PatBlt(context->hDC, prcCurrent->left, prcCurrent->top,
514 Width, prcCurrent->bottom - prcCurrent->top, PATCOPY);
515 PatBlt(context->hDC, prcCurrent->left, prcCurrent->bottom - 1,
516 prcCurrent->right - prcCurrent->left, -Height, PATCOPY);
517 PatBlt(context->hDC, prcCurrent->right - 1, prcCurrent->top,
518 -Width, prcCurrent->bottom - prcCurrent->top, PATCOPY);
519
520 InflateRect(prcCurrent, -Width, -Height);
521 }
522}
#define WS_EX_DLGMODALFRAME
Definition: pedump.c:645
#define WS_BORDER
Definition: pedump.c:625
#define WS_DLGFRAME
Definition: pedump.c:626
Definition: http.c:7252
int32_t INT
Definition: typedefs.h:58
_In_ HFONT _Out_ PUINT _Out_ PUINT Width
Definition: font.h:89
_In_ HFONT _Out_ PUINT Height
Definition: font.h:88
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
#define PATCOPY
Definition: wingdi.h:335
BOOL WINAPI PatBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
#define BDR_SUNKENINNER
Definition: winuser.h:445
#define COLOR_WINDOWFRAME
Definition: winuser.h:919
HBRUSH WINAPI GetSysColorBrush(_In_ int)
#define SM_CXFRAME
Definition: winuser.h:994
#define BF_ADJUST
Definition: winuser.h:470
#define BF_FLAT
Definition: winuser.h:471
#define SM_CYFRAME
Definition: winuser.h:996
BOOL WINAPI DrawEdge(_In_ HDC, _Inout_ LPRECT, _In_ UINT, _In_ UINT)
#define COLOR_ACTIVEBORDER
Definition: winuser.h:923
#define SM_CXDLGFRAME
Definition: winuser.h:966
#define SM_CYDLGFRAME
Definition: winuser.h:968
#define COLOR_INACTIVEBORDER
Definition: winuser.h:924
#define BF_RECT
Definition: winuser.h:462
#define EDGE_RAISED
Definition: winuser.h:450
#define COLOR_3DFACE
Definition: winuser.h:929

Referenced by ThemePaintWindow().

◆ DrawNCPreview()

HRESULT WINAPI DrawNCPreview ( HDC  hDC,
DWORD  DNCP_Flag,
LPRECT  prcPreview,
LPCWSTR  pszThemeFileName,
LPCWSTR  pszColorName,
LPCWSTR  pszSizeName,
PNONCLIENTMETRICSW  pncMetrics,
COLORREF lpaRgbValues 
)

Definition at line 1218 of file nonclient.c.

1226{
1227 WNDCLASSEXW DummyPreviewWindowClass;
1228 HWND hwndDummy;
1229 HRESULT hres;
1230 HTHEMEFILE hThemeFile;
1232 LPWSTR szText;
1233 int len;
1234
1235 /* Create a dummy window that will be used to trick the paint funtions */
1236 memset(&DummyPreviewWindowClass, 0, sizeof(DummyPreviewWindowClass));
1237 DummyPreviewWindowClass.cbSize = sizeof(DummyPreviewWindowClass);
1238 DummyPreviewWindowClass.lpszClassName = L"DummyPreviewWindowClass";
1239 DummyPreviewWindowClass.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
1240 DummyPreviewWindowClass.hInstance = hDllInst;
1241 DummyPreviewWindowClass.lpfnWndProc = DefWindowProcW;
1242 if (!RegisterClassExW(&DummyPreviewWindowClass))
1243 return E_FAIL;
1244
1245 hwndDummy = CreateWindowExW(0, L"DummyPreviewWindowClass", NULL, WS_OVERLAPPEDWINDOW | WS_VSCROLL, 30, 30, 300, 150, 0, 0, hDllInst, NULL);
1246 if (!hwndDummy)
1247 return E_FAIL;
1248
1249 hres = OpenThemeFile(pszThemeFileName, pszColorName, pszSizeName, &hThemeFile,0);
1250 if (FAILED(hres))
1251 return hres;
1252
1253 /* Initialize the special draw context for the preview */
1254 context.hDC = hDC;
1255 context.hWnd = hwndDummy;
1256 context.theme = OpenThemeDataFromFile(hThemeFile, hwndDummy, L"WINDOW", 0);
1257 if (!context.theme)
1258 return E_FAIL;
1259 context.scrolltheme = OpenThemeDataFromFile(hThemeFile, hwndDummy, L"SCROLLBAR", 0);
1260 if (!context.scrolltheme)
1261 return E_FAIL;
1262 context.wi.cbSize = sizeof(context.wi);
1263 if (!GetWindowInfo(hwndDummy, &context.wi))
1264 return E_FAIL;
1265 context.wi.dwStyle |= WS_VISIBLE;
1266
1267 context.hRgn = CreateRectRgnIndirect(&context.wi.rcWindow);
1268 RECT rcAdjPreview = { prcPreview->left, prcPreview->top, prcPreview->right, prcPreview->bottom };
1269 INT previewWidth = rcAdjPreview.right - rcAdjPreview.left;
1270 INT previewHeight = rcAdjPreview.bottom - rcAdjPreview.top;
1271
1272 /* Draw inactive preview window */
1273 context.Active = FALSE;
1275 DrawWindowForNCPreview(hDC, &context, rcAdjPreview.left, rcAdjPreview.top, rcAdjPreview.right - 17, rcAdjPreview.bottom - 20, TRUE, NULL);
1276
1277 /* Draw active preview window */
1278 context.Active = TRUE;
1280
1281 DWORD textDrawFlags = DT_NOPREFIX | DT_SINGLELINE | DT_WORDBREAK;
1282 RECT rcWindowClient;
1283 DrawWindowForNCPreview(hDC, &context, rcAdjPreview.left + 10, rcAdjPreview.top + 22, rcAdjPreview.right, rcAdjPreview.bottom, TRUE, &rcWindowClient);
1284 LOGFONTW lfText;
1285 HFONT textFont = NULL;
1286 if (SUCCEEDED(GetThemeSysFont(context.theme, TMT_MSGBOXFONT, &lfText)))
1287 textFont = CreateFontIndirectW(&lfText);
1288
1289 if (textFont)
1290 SelectFont(hDC, textFont);
1291
1293 len = LoadStringW(hDllInst, IDS_WINTEXT, (LPWSTR)&szText, 0);
1294 if (len > 0)
1295 DrawThemeText(context.theme, hDC, WP_DIALOG, 0, szText, len, DT_LEFT | DT_TOP | textDrawFlags, 0, &rcWindowClient);
1296
1297 /* Draw preview dialog window */
1300 SetWindowLongPtr(hwndDummy, GWL_STYLE, dwStyleNew);
1301 DWORD dwExStyleNew = WS_EX_DLGMODALFRAME;
1302 SetWindowLongPtr(hwndDummy, GWL_EXSTYLE, dwExStyleNew);
1303
1304 if (!GetWindowInfo(hwndDummy, &context.wi))
1305 return E_FAIL;
1306
1307 context.wi.dwStyle = WS_VISIBLE | dwStyleNew;
1308 context.wi.dwExStyle = dwExStyleNew;
1309
1310 INT msgBoxHCenter = rcAdjPreview.left + (previewWidth / 2);
1311 INT msgBoxVCenter = rcAdjPreview.top + (previewHeight / 2);
1312
1313 DrawWindowForNCPreview(hDC, &context, msgBoxHCenter - NC_PREVIEW_MSGBOX_HALF_WIDTH, msgBoxVCenter + NC_PREVIEW_MSGBOX_OFFSET_X, msgBoxHCenter + NC_PREVIEW_MSGBOX_HALF_WIDTH, msgBoxVCenter + NC_PREVIEW_MSGBOX_OFFSET_Y, FALSE, &rcWindowClient);
1314 DrawThemeBackground(context.theme, hDC, WP_DIALOG, 0, &rcWindowClient, NULL);
1315
1316 /* Draw preview dialog button */
1317 HTHEME hBtnTheme = OpenThemeDataFromFile(hThemeFile, hwndDummy, L"BUTTON", OTD_NONCLIENT);
1318 if (hBtnTheme)
1319 {
1320 INT btnCenterH = rcWindowClient.left + ((rcWindowClient.right - rcWindowClient.left) / 2);
1321 INT btnCenterV = rcWindowClient.top + ((rcWindowClient.bottom - rcWindowClient.top) / 2);
1322 RECT rcBtn = {btnCenterH - 40, btnCenterV - 15, btnCenterH + 40, btnCenterV + 15};
1323 int btnPart = BP_PUSHBUTTON;
1324 int btnState = PBS_DEFAULTED;
1325 DrawThemeBackground(hBtnTheme, hDC, btnPart, btnState, &rcBtn, NULL);
1326 MARGINS btnContentMargins;
1327 if (GetThemeMargins(hBtnTheme, hDC, btnPart, btnState, TMT_CONTENTMARGINS, NULL, &btnContentMargins) == S_OK)
1328 {
1329 rcBtn.left += btnContentMargins.cxLeftWidth;
1330 rcBtn.top += btnContentMargins.cyTopHeight;
1331 rcBtn.right -= btnContentMargins.cxRightWidth;
1332 rcBtn.bottom -= btnContentMargins.cyBottomHeight;
1333 }
1334
1335 LOGFONTW lfBtn;
1336 if ((GetThemeFont(hBtnTheme, hDC, btnPart, btnState, TMT_FONT, &lfBtn) != S_OK) && textFont)
1337 SelectFont(hDC, textFont);
1338
1339 len = LoadStringW(hDllInst, IDS_OK, (LPWSTR)&szText, 0);
1340 if (len > 0)
1341 DrawThemeText(hBtnTheme, hDC, btnPart, btnState, szText, len, DT_CENTER | DT_VCENTER | textDrawFlags, 0, &rcBtn);
1342 CloseThemeData(hBtnTheme);
1343 }
1344
1345 context.hDC = NULL;
1346 CloseThemeData (context.theme);
1347 CloseThemeData (context.scrolltheme);
1349
1350 /* Cleanup */
1351 DestroyWindow(hwndDummy);
1352 UnregisterClassW(L"DummyPreviewWindowClass", hDllInst);
1353
1354 return S_OK;
1355}
static HDC hDC
Definition: 3dtext.c:33
#define IDS_OK
Definition: resource.h:19
#define E_FAIL
Definition: ddrawi.h:102
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define IDS_WINTEXT
Definition: resource.h:107
HRESULT WINAPI DrawThemeBackground(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, const RECT *pClipRect)
Definition: draw.c:128
HRESULT WINAPI DrawThemeText(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, LPCWSTR pszText, int iCharCount, DWORD dwTextFlags, DWORD dwTextFlags2, const RECT *pRect)
Definition: draw.c:1377
COLORREF WINAPI GetThemeSysColor(HTHEME hTheme, int iColorID)
Definition: metric.c:58
HRESULT WINAPI GetThemeSysFont(HTHEME hTheme, int iFontID, LOGFONTW *plf)
Definition: metric.c:91
static void DrawWindowForNCPreview(_In_ HDC hDC, _In_ PDRAW_CONTEXT pcontext, _In_ INT left, _In_ INT top, _In_ INT right, _In_ INT bottom, _In_ BOOL drawClientAreaColor, _Out_opt_ LPRECT prcClient)
Definition: nonclient.c:1088
void ThemeCleanupDrawContext(PDRAW_CONTEXT pcontext)
Definition: nonclient.c:182
#define NC_PREVIEW_MSGBOX_HALF_WIDTH
Definition: nonclient.c:11
#define NC_PREVIEW_MSGBOX_OFFSET_Y
Definition: nonclient.c:13
VOID SetWindowResourceText(_In_ HWND hwnd, _In_ UINT uID)
Definition: nonclient.c:1197
#define NC_PREVIEW_MSGBOX_OFFSET_X
Definition: nonclient.c:12
HRESULT WINAPI GetThemeFont(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, int iPropId, LOGFONTW *pFont)
Definition: property.c:108
HRESULT WINAPI GetThemeMargins(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, int iPropId, RECT *prc, MARGINS *pMargins)
Definition: property.c:216
#define IDS_INACTIVEWIN
Definition: resource.h:14
#define IDS_MESSAGEBOX
Definition: resource.h:12
#define IDS_ACTIVEWIN
Definition: resource.h:13
HINSTANCE hDllInst
Definition: system.c:45
HTHEME WINAPI OpenThemeDataFromFile(HTHEMEFILE hThemeFile, HWND hwnd, LPCWSTR pszClassList, DWORD flags)
Definition: system.c:827
HRESULT WINAPI OpenThemeFile(LPCWSTR pszThemeFileName, LPCWSTR pszColorName, LPCWSTR pszSizeName, HTHEMEFILE *hThemeFile, DWORD unknown)
Definition: system.c:1101
HRESULT WINAPI CloseThemeData(HTHEME hTheme)
Definition: system.c:950
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLsizei len
Definition: glext.h:6722
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
HRESULT hres
Definition: protocol.c:465
static HTHEME(WINAPI *pOpenThemeDataEx)(HWND
#define L(x)
Definition: ntvdm.h:50
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define WS_OVERLAPPED
Definition: pedump.c:615
#define WS_VISIBLE
Definition: pedump.c:620
#define memset(x, y, z)
Definition: compat.h:39
Definition: misc.c:279
int cyBottomHeight
Definition: misc.c:283
int cyTopHeight
Definition: misc.c:282
int cxRightWidth
Definition: misc.c:281
int cxLeftWidth
Definition: misc.c:280
LPCWSTR lpszClassName
Definition: winuser.h:3226
HBRUSH hbrBackground
Definition: winuser.h:3224
WNDPROC lpfnWndProc
Definition: winuser.h:3218
UINT cbSize
Definition: winuser.h:3216
HINSTANCE hInstance
Definition: winuser.h:3221
#define SetWindowLongPtr
Definition: treelist.c:70
@ PBS_DEFAULTED
Definition: vsstyle.h:90
@ BP_PUSHBUTTON
Definition: vsstyle.h:74
@ WP_DIALOG
Definition: vsstyle.h:1639
#define TMT_CONTENTMARGINS
Definition: vssym32.h:324
#define TMT_WINDOWTEXT
Definition: vssym32.h:207
#define TMT_FONT
Definition: vssym32.h:144
#define TMT_MSGBOXFONT
Definition: vssym32.h:168
#define SelectFont(hdc, hfont)
Definition: windowsx.h:516
HFONT WINAPI CreateFontIndirectW(_In_ const LOGFONTW *)
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:918
HRGN WINAPI CreateRectRgnIndirect(_In_ LPCRECT)
#define DT_NOPREFIX
Definition: winuser.h:537
#define COLOR_WINDOW
Definition: winuser.h:918
#define DT_CENTER
Definition: winuser.h:527
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define DT_SINGLELINE
Definition: winuser.h:540
#define DT_LEFT
Definition: winuser.h:534
#define DT_TOP
Definition: winuser.h:542
HWND WINAPI CreateWindowExW(_In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, _In_opt_ LPCWSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
#define DT_WORDBREAK
Definition: winuser.h:544
ATOM WINAPI RegisterClassExW(_In_ CONST WNDCLASSEXW *)
#define DT_VCENTER
Definition: winuser.h:543
BOOL WINAPI UnregisterClassW(_In_ LPCWSTR, HINSTANCE)
BOOL WINAPI DestroyWindow(_In_ HWND)
#define GWL_EXSTYLE
Definition: winuser.h:851
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by DrawThemePreview().

◆ DrawWindowForNCPreview()

static void DrawWindowForNCPreview ( _In_ HDC  hDC,
_In_ PDRAW_CONTEXT  pcontext,
_In_ INT  left,
_In_ INT  top,
_In_ INT  right,
_In_ INT  bottom,
_In_ BOOL  drawClientAreaColor,
_Out_opt_ LPRECT  prcClient 
)
static

Definition at line 1088 of file nonclient.c.

1097{
1098 if (!hDC)
1099 return;
1100
1101 if (!pcontext)
1102 return;
1103
1104 DWORD dwStyle = pcontext->wi.dwStyle;
1105 DWORD dwExStyle = pcontext->wi.dwExStyle;
1106 pcontext->CaptionHeight = pcontext->wi.cyWindowBorders + GetThemeSysSize(pcontext->theme, dwExStyle & WS_EX_TOOLWINDOW ? SM_CYSMSIZE : SM_CYSIZE);
1107 /* FIXME: still need to use ncmetrics from parameters for window border width */
1108
1109 RECT rcWindowPrev = { pcontext->wi.rcWindow.left, pcontext->wi.rcWindow.top, pcontext->wi.rcWindow.right, pcontext->wi.rcWindow.bottom };
1110 RECT rcClientPrev = { pcontext->wi.rcClient.left, pcontext->wi.rcClient.top, pcontext->wi.rcClient.right, pcontext->wi.rcClient.bottom };
1112 RECT rcWindowNew = { left, top, right, bottom };
1113 pcontext->wi.rcWindow = rcWindowNew;
1114
1115 BOOL hasVScrollBar = dwStyle & WS_VSCROLL;
1116 if (hasVScrollBar)
1117 {
1118 SCROLLINFO dummyScrollInfo;
1119 EnableScrollBar(pcontext->hWnd, SB_VERT, ESB_ENABLE_BOTH);
1120
1121 dummyScrollInfo.cbSize = sizeof(dummyScrollInfo);
1122 dummyScrollInfo.fMask = SIF_DISABLENOSCROLL | SIF_POS | SIF_RANGE;
1123 dummyScrollInfo.nMin = 0;
1124 dummyScrollInfo.nMax = rcWindowNew.bottom - rcWindowNew.top;
1125 dummyScrollInfo.nPos = 0;
1126 SetScrollInfo(pcontext->hWnd, SB_VERT, &dummyScrollInfo, TRUE);
1127 }
1128
1129 SetViewportOrgEx(hDC, rcWindowNew.left, rcWindowNew.top, NULL);
1130
1131 INT offsetX = -rcWindowNew.left;
1132 INT offsetY = -rcWindowNew.top;
1133 OffsetRect(&rcWindowNew, offsetX, offsetY);
1134 ThemeCalculateCaptionButtonsPosEx(&pcontext->wi, pcontext->hWnd, pcontext->theme, pcontext->CaptionHeight - pcontext->wi.cyWindowBorders);
1135
1136 INT leftBorderInset = pcontext->wi.cxWindowBorders;
1137 INT titleBarInset = pcontext->CaptionHeight; // + pcontext->wi.cyWindowBorders;
1138 INT rightBorderInset = pcontext->wi.cxWindowBorders;
1139 INT bottomBorderInset = pcontext->wi.cyWindowBorders;
1140
1141 RECT rcClientNew;
1142 if (GetWindowRect(pcontext->hWnd, &rcClientNew))
1143 {
1144 rcClientNew.left += leftBorderInset;
1145 rcClientNew.top += titleBarInset;
1146 rcClientNew.right -= rightBorderInset;
1147 rcClientNew.bottom -= bottomBorderInset;
1148 }
1149 pcontext->wi.rcClient = rcClientNew;
1150
1151 pcontext->wi.dwStyle &= ~(WS_HSCROLL | WS_VSCROLL);
1152 ThemePaintWindow(pcontext, &rcWindowNew, FALSE);
1153 pcontext->wi.dwStyle = dwStyle;
1154
1155 if (hasVScrollBar && IsScrollBarVisible(pcontext->hWnd, OBJID_VSCROLL))
1156 {
1157 SCROLLBARINFO sbi;
1158 sbi.cbSize = sizeof(sbi);
1159 GetScrollBarInfo(pcontext->hWnd, OBJID_VSCROLL, &sbi);
1160 INT scWidth = sbi.rcScrollBar.right - sbi.rcScrollBar.left;
1161
1162 sbi.rcScrollBar.right = rcClientNew.right;
1163 rcClientNew.right -= scWidth;
1164 sbi.rcScrollBar.left = rcClientNew.right;
1165
1166 sbi.rcScrollBar.top = rcClientNew.top;
1167 sbi.rcScrollBar.bottom = rcClientNew.bottom;
1168
1169 ThemeDrawScrollBarEx(pcontext, SB_VERT, &sbi, NULL);
1170 }
1171 pcontext->wi.rcClient = rcClientNew;
1172
1173 OffsetRect(&rcClientNew, -pcontext->wi.rcWindow.left, -pcontext->wi.rcWindow.top);
1174
1175 if (drawClientAreaColor)
1176 {
1177 HBRUSH hbrWindow = GetThemeSysColorBrush(pcontext->theme, COLOR_WINDOW);
1178 FillRect(hDC, &rcClientNew, hbrWindow);
1179 DeleteObject(hbrWindow);
1180 }
1181
1182 pcontext->wi.rcWindow = rcWindowPrev;
1183 pcontext->wi.rcClient = rcClientPrev;
1184
1185 SetViewportOrgEx(hDC, 0, 0, NULL);
1186 if (prcClient != NULL)
1187 {
1188 prcClient->left = rcClientNew.left;
1189 prcClient->top = rcClientNew.top;
1190 prcClient->right = rcClientNew.right;
1191 prcClient->bottom = rcClientNew.bottom;
1192 OffsetRect(prcClient, -offsetX, -offsetY);
1193 }
1194}
HBRUSH WINAPI GetThemeSysColorBrush(HTHEME hTheme, int iColorID)
Definition: metric.c:82
int WINAPI GetThemeSysSize(HTHEME hTheme, int iSizeID)
Definition: metric.c:154
static void ThemePaintWindow(PDRAW_CONTEXT pcontext, RECT *prcCurrent, BOOL bDoDoubleBuffering)
Definition: nonclient.c:569
static void ThemeCalculateCaptionButtonsPosEx(WINDOWINFO *wi, HWND hWnd, HTHEME htheme, INT buttonHeight)
Definition: nonclient.c:215
BOOL IsScrollBarVisible(HWND hWnd, INT hBar)
Definition: nonclient.c:35
pKey DeleteObject()
GLdouble GLdouble GLdouble GLdouble top
Definition: glext.h:10859
GLdouble GLdouble right
Definition: glext.h:10859
GLint left
Definition: glext.h:7726
GLint GLint bottom
Definition: glext.h:7726
void ThemeDrawScrollBarEx(PDRAW_CONTEXT pcontext, INT nBar, PSCROLLBARINFO psbi, POINT *pt)
Definition: ncscrollbar.c:276
#define OBJID_VSCROLL
Definition: winable.h:20
BOOL WINAPI SetViewportOrgEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
Definition: coord.c:655
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
#define SWP_NOACTIVATE
Definition: winuser.h:1242
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
#define SIF_RANGE
Definition: winuser.h:1235
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define SWP_DRAWFRAME
Definition: winuser.h:1239
#define SB_VERT
Definition: winuser.h:553
#define SWP_NOCOPYBITS
Definition: winuser.h:1243
#define SIF_DISABLENOSCROLL
Definition: winuser.h:1236
#define SIF_POS
Definition: winuser.h:1234
BOOL WINAPI OffsetRect(_Inout_ LPRECT, _In_ int, _In_ int)
#define SM_CYSMSIZE
Definition: winuser.h:1016
int WINAPI SetScrollInfo(_In_ HWND, _In_ int, _In_ LPCSCROLLINFO, _In_ BOOL)
#define SWP_NOZORDER
Definition: winuser.h:1247
BOOL WINAPI EnableScrollBar(_In_ HWND, _In_ UINT, _In_ UINT)
#define ESB_ENABLE_BOTH
Definition: winuser.h:563
BOOL WINAPI GetScrollBarInfo(_In_ HWND, _In_ LONG, _Inout_ PSCROLLBARINFO)

Referenced by DrawNCPreview().

◆ IsScrollBarVisible()

BOOL IsScrollBarVisible ( HWND  hWnd,
INT  hBar 
)

Definition at line 35 of file nonclient.c.

36{
37 SCROLLBARINFO sbi = {sizeof(SCROLLBARINFO)};
38
39 if (!GetScrollBarInfo(hWnd, hBar, &sbi))
40 return FALSE;
41
42 return !(sbi.rgstate[0] & STATE_SYSTEM_OFFSCREEN);
43}
DWORD rgstate[CCHILDREN_SCROLLBAR+1]
Definition: winuser.h:3754
#define STATE_SYSTEM_OFFSCREEN
Definition: winuser.h:2878
struct tagSCROLLBARINFO SCROLLBARINFO

Referenced by DrawWindowForNCPreview(), and ThemePaintWindow().

◆ IsWindowActive()

static BOOL IsWindowActive ( HWND  hWnd,
DWORD  ExStyle 
)
static

Definition at line 16 of file nonclient.c.

17{
18 BOOL ret;
19
21 {
23 if (ret)
25 }
26 else
27 {
29 }
30
31 return ret;
32}
const DWORD ExStyle
Definition: appswitch.c:72
HANDLE HWND
Definition: compat.h:19
int ret
HWND WINAPI GetForegroundWindow(void)
Definition: ntwrapper.h:392
#define WS_EX_MDICHILD
Definition: winuser.h:394
BOOL WINAPI IsChild(_In_ HWND, _In_ HWND)
#define WM_MDIGETACTIVE
Definition: winuser.h:1821
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by ThemeInitDrawContext().

◆ SetWindowResourceText()

VOID SetWindowResourceText ( _In_ HWND  hwnd,
_In_ UINT  uID 
)

Definition at line 1197 of file nonclient.c.

1200{
1201 LPWSTR lpszDestBuf = NULL, lpszResourceString = NULL;
1202 size_t iStrSize = 0;
1203
1204 /* When passing a zero-length buffer size, LoadString() returns
1205 * a read-only pointer buffer to the program's resource string. */
1206 iStrSize = LoadStringW(hDllInst, uID, (LPWSTR)&lpszResourceString, 0);
1207
1208 if (lpszResourceString && ((lpszDestBuf = HeapAlloc(GetProcessHeap(), 0, (iStrSize + 1) * sizeof(WCHAR))) != NULL))
1209 {
1210 wcsncpy(lpszDestBuf, lpszResourceString, iStrSize);
1211 lpszDestBuf[iStrSize] = UNICODE_NULL; // NULL-terminate the string
1212
1213 SetWindowTextW(hwnd, lpszDestBuf);
1214 HeapFree(GetProcessHeap(), 0, lpszDestBuf);
1215 }
1216}
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define UNICODE_NULL
_CRTIMP wchar_t *__cdecl wcsncpy(wchar_t *_Dest, const wchar_t *_Source, size_t _Count)
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by DrawNCPreview().

◆ ThemeCalculateCaptionButtonsPos()

void ThemeCalculateCaptionButtonsPos ( HWND  hWnd,
HTHEME  htheme 
)

Definition at line 270 of file nonclient.c.

271{
272 INT btnHeight;
273 WINDOWINFO wi = {sizeof(wi)};
274
275 if (!GetWindowInfo(hWnd, &wi))
276 return;
278
279 ThemeCalculateCaptionButtonsPosEx(&wi, hWnd, htheme, btnHeight);
280}

Referenced by ThemePreWindowProc().

◆ ThemeCalculateCaptionButtonsPosEx()

static void ThemeCalculateCaptionButtonsPosEx ( WINDOWINFO wi,
HWND  hWnd,
HTHEME  htheme,
INT  buttonHeight 
)
static

Definition at line 215 of file nonclient.c.

216{
217 PWND_DATA pwndData;
218 DWORD style;
219 INT captionBtnWidth, captionBtnHeight, iPartId, i;
220 RECT rcCurrent;
221 SIZE ButtonSize;
222
223 /* First of all check if we have something to do here */
226 return;
227
228 /* Get theme data for this window */
229 pwndData = ThemeGetWndData(hWnd);
230 if (pwndData == NULL)
231 return;
232
233 if (!htheme)
234 {
235 htheme = GetNCCaptionTheme(hWnd, style);
236 if (!htheme)
237 return;
238 }
239
240 /* Calculate the area of the caption */
241 rcCurrent.top = rcCurrent.left = 0;
242 rcCurrent.right = wi->rcWindow.right - wi->rcWindow.left;
243 rcCurrent.bottom = wi->rcWindow.bottom - wi->rcWindow.top;
244
245 /* Add a padding around the objects of the caption */
246 InflateRect(&rcCurrent, -(int)wi->cyWindowBorders-BUTTON_GAP_SIZE,
248
250
251 GetThemePartSize(htheme, NULL, iPartId, 0, NULL, TS_MIN, &ButtonSize);
252
253 captionBtnWidth = MulDiv(ButtonSize.cx, buttonHeight, ButtonSize.cy);
254
255 captionBtnHeight = buttonHeight - 4;
256 captionBtnWidth -= 4;
257
258 for (i = CLOSEBUTTON; i <= HELPBUTTON; i++)
259 {
260 SetRect(&pwndData->rcCaptionButtons[i],
261 rcCurrent.right - captionBtnWidth,
262 rcCurrent.top,
263 rcCurrent.right,
264 rcCurrent.top + captionBtnHeight);
265
266 rcCurrent.right -= captionBtnWidth + BUTTON_GAP_SIZE;
267 }
268}
Arabic default style
Definition: afstyles.h:94
HRESULT WINAPI GetThemePartSize(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, RECT *prc, THEMESIZE eSize, SIZE *psz)
Definition: draw.c:1777
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
INT WINAPI MulDiv(INT nNumber, INT nNumerator, INT nDenominator)
Definition: muldiv.c:25
LONG cx
Definition: kdterminal.h:27
LONG cy
Definition: kdterminal.h:28
HTHEME GetNCCaptionTheme(HWND hWnd, DWORD style)
Definition: themehooks.c:88
#define BUTTON_GAP_SIZE
Definition: uxthemep.h:240
@ HELPBUTTON
Definition: uxthemep.h:211
@ WP_SMALLCLOSEBUTTON
Definition: vsstyle.h:1629
@ WP_CLOSEBUTTON
Definition: vsstyle.h:1628
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)

Referenced by DrawWindowForNCPreview(), and ThemeCalculateCaptionButtonsPos().

◆ ThemeCleanupDrawContext()

void ThemeCleanupDrawContext ( PDRAW_CONTEXT  pcontext)

Definition at line 182 of file nonclient.c.

183{
184 ReleaseDC(pcontext->hWnd ,pcontext->hDC);
185
186 if (pcontext->hRgn != NULL)
187 {
188 DeleteObject(pcontext->hRgn);
189 }
190}
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)

Referenced by DrawNCPreview(), SCROLL_HandleScrollEvent(), ThemeHandleButton(), ThemeHandleNcMouseLeave(), ThemeHandleNcMouseMove(), and ThemeHandleNCPaint().

◆ ThemeDrawBorders()

static void ThemeDrawBorders ( PDRAW_CONTEXT  pcontext,
RECT prcCurrent 
)
static

Definition at line 435 of file nonclient.c.

436{
437 RECT rcPart;
438 int iState = pcontext->Active ? FS_ACTIVE : FS_INACTIVE;
439
440 /* Draw the bottom border */
441 rcPart = *prcCurrent;
442 rcPart.top = rcPart.bottom - pcontext->wi.cyWindowBorders;
443 prcCurrent->bottom = rcPart.top;
444 DrawThemeBackground(pcontext->theme, pcontext->hDC, WP_FRAMEBOTTOM, iState, &rcPart, NULL);
445
446 /* Draw the left border */
447 rcPart = *prcCurrent;
448 rcPart.right = rcPart.left + pcontext->wi.cxWindowBorders ;
449 prcCurrent->left = rcPart.right;
450 DrawThemeBackground(pcontext->theme, pcontext->hDC,WP_FRAMELEFT, iState, &rcPart, NULL);
451
452 /* Draw the right border */
453 rcPart = *prcCurrent;
454 rcPart.left = rcPart.right - pcontext->wi.cxWindowBorders;
455 prcCurrent->right = rcPart.left;
456 DrawThemeBackground(pcontext->theme, pcontext->hDC,WP_FRAMERIGHT, iState, &rcPart, NULL);
457}
WINDOWINFO wi
Definition: uxthemep.h:196
HTHEME theme
Definition: uxthemep.h:193
@ WP_FRAMERIGHT
Definition: vsstyle.h:1618
@ WP_FRAMEBOTTOM
Definition: vsstyle.h:1619
@ WP_FRAMELEFT
Definition: vsstyle.h:1617
@ FS_INACTIVE
Definition: vsstyle.h:1655
@ FS_ACTIVE
Definition: vsstyle.h:1654

Referenced by ThemePaintWindow().

◆ ThemeDrawCaption()

static void ThemeDrawCaption ( PDRAW_CONTEXT  pcontext,
RECT prcCurrent 
)
static

Definition at line 371 of file nonclient.c.

372{
373 RECT rcPart;
374 int iPart, iState;
375 HICON hIcon;
376
377 // See also win32ss/user/ntuser/nonclient.c!UserDrawCaptionBar
378 // and win32ss/user/ntuser/nonclient.c!UserDrawCaption
379 if ((pcontext->wi.dwStyle & WS_SYSMENU) && !(pcontext->wi.dwExStyle & WS_EX_TOOLWINDOW))
380 hIcon = UserGetWindowIcon(pcontext);
381 else
382 hIcon = NULL;
383
384 /* Get the caption part and state id */
385 if (pcontext->wi.dwStyle & WS_MINIMIZE)
386 iPart = WP_MINCAPTION;
387 else if (pcontext->wi.dwExStyle & WS_EX_TOOLWINDOW)
388 iPart = WP_SMALLCAPTION;
389 else if (pcontext->wi.dwStyle & WS_MAXIMIZE)
390 iPart = WP_MAXCAPTION;
391 else
392 iPart = WP_CAPTION;
393
394 iState = pcontext->Active ? FS_ACTIVE : FS_INACTIVE;
395
396 /* Draw the caption background */
397 rcPart = *prcCurrent;
398 rcPart.bottom = rcPart.top + pcontext->CaptionHeight;
399 prcCurrent->top = rcPart.bottom;
400 DrawThemeBackground(pcontext->theme, pcontext->hDC,iPart,iState,&rcPart,NULL);
401
402 /* Add a padding around the objects of the caption */
403 InflateRect(&rcPart, -(int)pcontext->wi.cyWindowBorders-BUTTON_GAP_SIZE,
404 -(int)pcontext->wi.cyWindowBorders-BUTTON_GAP_SIZE);
405
406 /* Draw the caption buttons */
407 if (pcontext->wi.dwStyle & WS_SYSMENU)
408 {
409 iState = pcontext->Active ? BUTTON_NORMAL : BUTTON_INACTIVE;
410
411 ThemeDrawCaptionButton(pcontext, &rcPart, CLOSEBUTTON, iState);
412 ThemeDrawCaptionButton(pcontext, &rcPart, MAXBUTTON, iState);
413 ThemeDrawCaptionButton(pcontext, &rcPart, MINBUTTON, iState);
414 ThemeDrawCaptionButton(pcontext, &rcPart, HELPBUTTON, iState);
415 }
416
417 rcPart.top += 3 ;
418
419 /* Draw the icon */
420 if (hIcon)
421 {
422 int IconHeight = GetSystemMetrics(SM_CYSMICON);
423 int IconWidth = GetSystemMetrics(SM_CXSMICON);
424 DrawIconEx(pcontext->hDC, rcPart.left, rcPart.top , hIcon, IconWidth, IconHeight, 0, NULL, DI_NORMAL);
425 rcPart.left += IconWidth + 4;
426 }
427
428 rcPart.right -= 4;
429
430 /* Draw the caption */
431 ThemeDrawCaptionText(pcontext, &rcPart, iPart, iState);
432}
static HICON UserGetWindowIcon(PDRAW_CONTEXT pcontext)
Definition: nonclient.c:63
static void ThemeDrawCaptionButton(PDRAW_CONTEXT pcontext, RECT *prcCurrent, CAPTIONBUTTON buttonId, INT iStateId)
Definition: nonclient.c:283
HRESULT WINAPI ThemeDrawCaptionText(PDRAW_CONTEXT pcontext, RECT *pRect, int iPartId, int iStateId)
Definition: nonclient.c:88
static HICON
Definition: imagelist.c:84
HICON hIcon
Definition: msconfig.c:44
#define WS_MAXIMIZE
Definition: pedump.c:623
int CaptionHeight
Definition: uxthemep.h:199
@ BUTTON_NORMAL
Definition: uxthemep.h:220
@ BUTTON_INACTIVE
Definition: uxthemep.h:224
@ WP_CAPTION
Definition: vsstyle.h:1611
@ WP_MAXCAPTION
Definition: vsstyle.h:1615
@ WP_MINCAPTION
Definition: vsstyle.h:1613
@ WP_SMALLCAPTION
Definition: vsstyle.h:1612
#define DI_NORMAL
Definition: wingdi.h:72
#define SM_CYSMICON
Definition: winuser.h:1013
BOOL WINAPI DrawIconEx(_In_ HDC, _In_ int, _In_ int, _In_ HICON, _In_ int, _In_ int, _In_ UINT, _In_opt_ HBRUSH, _In_ UINT)
Definition: cursoricon.c:2028

Referenced by ThemePaintWindow().

◆ ThemeDrawCaptionButton()

static void ThemeDrawCaptionButton ( PDRAW_CONTEXT  pcontext,
RECT prcCurrent,
CAPTIONBUTTON  buttonId,
INT  iStateId 
)
static

Definition at line 283 of file nonclient.c.

287{
288 INT iPartId;
289 HMENU SysMenu;
290 UINT MenuState;
291 PWND_DATA pwndData = ThemeGetWndData(pcontext->hWnd);
292 if (!pwndData)
293 return;
294
295 switch(buttonId)
296 {
297 case CLOSEBUTTON:
298 SysMenu = GetSystemMenu(pcontext->hWnd, FALSE);
299 MenuState = GetMenuState(SysMenu, SC_CLOSE, MF_BYCOMMAND);
300 if (!(pcontext->wi.dwStyle & WS_SYSMENU) || (MenuState & (MF_GRAYED | MF_DISABLED)) || pcontext->wi.dwStyle & CS_NOCLOSE)
301 {
302 iStateId = (pcontext->Active ? BUTTON_DISABLED : BUTTON_INACTIVE_DISABLED);
303 }
304
306 break;
307
308 case MAXBUTTON:
309 if (!(pcontext->wi.dwStyle & WS_MAXIMIZEBOX))
310 {
311 if (!(pcontext->wi.dwStyle & WS_MINIMIZEBOX))
312 return;
313 else
314 iStateId = (pcontext->Active ? BUTTON_DISABLED : BUTTON_INACTIVE_DISABLED);
315 }
316
317 iPartId = pcontext->wi.dwStyle & WS_MAXIMIZE ? WP_RESTOREBUTTON : WP_MAXBUTTON;
318 break;
319
320 case MINBUTTON:
321 if (!(pcontext->wi.dwStyle & WS_MINIMIZEBOX))
322 {
323 if (!(pcontext->wi.dwStyle & WS_MAXIMIZEBOX))
324 return;
325 else
326 iStateId = (pcontext->Active ? BUTTON_DISABLED : BUTTON_INACTIVE_DISABLED);
327 }
328
329 iPartId = pcontext->wi.dwStyle & WS_MINIMIZE ? WP_RESTOREBUTTON : WP_MINBUTTON;
330 break;
331
332 default:
333 //FIXME: Implement Help Button
334 return;
335 }
336
337 if (prcCurrent)
338 prcCurrent->right = pwndData->rcCaptionButtons[buttonId].left;
339
340 DrawThemeBackground(pcontext->theme, pcontext->hDC, iPartId, iStateId, &pwndData->rcCaptionButtons[buttonId], NULL);
341}
unsigned int UINT
Definition: ndis.h:50
#define WS_MAXIMIZEBOX
Definition: pedump.c:632
#define WS_MINIMIZEBOX
Definition: pedump.c:631
@ BUTTON_DISABLED
Definition: uxthemep.h:223
@ BUTTON_INACTIVE_DISABLED
Definition: uxthemep.h:227
@ WP_MAXBUTTON
Definition: vsstyle.h:1627
@ WP_MINBUTTON
Definition: vsstyle.h:1625
@ WP_RESTOREBUTTON
Definition: vsstyle.h:1631
#define MF_BYCOMMAND
Definition: winuser.h:202
UINT WINAPI GetMenuState(_In_ HMENU, _In_ UINT, _In_ UINT)
HMENU WINAPI GetSystemMenu(_In_ HWND, _In_ BOOL)
#define SC_CLOSE
Definition: winuser.h:2592
#define CS_NOCLOSE
Definition: winuser.h:654
#define MF_GRAYED
Definition: winuser.h:129
#define MF_DISABLED
Definition: winuser.h:130

Referenced by ThemeDrawCaption(), and ThemeDrawCaptionButtons().

◆ ThemeDrawCaptionButtons()

static void ThemeDrawCaptionButtons ( PDRAW_CONTEXT  pcontext,
DWORD  htHot,
DWORD  htDown 
)
static

Definition at line 356 of file nonclient.c.

357{
358 /* Draw the buttons */
360 ThemeGetButtonState(HTCLOSE, htHot, htDown, pcontext->Active));
362 ThemeGetButtonState(HTMAXBUTTON, htHot, htDown, pcontext->Active));
364 ThemeGetButtonState(HTMINBUTTON, htHot, htDown, pcontext->Active));
366 ThemeGetButtonState(HTHELP, htHot, htDown, pcontext->Active));
367}
static DWORD ThemeGetButtonState(DWORD htCurrect, DWORD htHot, DWORD htDown, BOOL Active)
Definition: nonclient.c:344
#define HTHELP
Definition: winuser.h:2500

Referenced by ThemeHandleButton(), ThemeHandleNcMouseLeave(), and ThemeHandleNcMouseMove().

◆ ThemeDrawCaptionText()

HRESULT WINAPI ThemeDrawCaptionText ( PDRAW_CONTEXT  pcontext,
RECT pRect,
int  iPartId,
int  iStateId 
)

Definition at line 88 of file nonclient.c.

89{
90 HRESULT hr;
92 HGDIOBJ oldFont = NULL;
93 LOGFONTW logfont;
94 COLORREF textColor;
95 COLORREF oldTextColor;
96 int align = CA_LEFT;
97 int drawStyles = DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS;
98
99 WCHAR buffer[50];
100 WCHAR *pszText = buffer;
101 INT len;
102
103 len = InternalGetWindowText(pcontext->hWnd, NULL, 0);
104 if (!len)
105 return S_OK;
106
107 len++; /* From now on this is the size of the buffer so include the null */
108
109 if (len > ARRAYSIZE(buffer))
110 {
111 pszText = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
112 if (!pszText)
113 return E_OUTOFMEMORY;
114 }
115
116 InternalGetWindowText(pcontext->hWnd, pszText, len);
117
118 hr = GetThemeSysFont(pcontext->theme, TMT_CAPTIONFONT, &logfont);
119 if (SUCCEEDED(hr))
120 hFont = CreateFontIndirectW(&logfont);
121
122 if (hFont)
123 oldFont = SelectObject(pcontext->hDC, hFont);
124
125 textColor = GetThemeSysColor(pcontext->theme, pcontext->Active ? COLOR_CAPTIONTEXT : COLOR_INACTIVECAPTIONTEXT);
126
127 GetThemeEnumValue(pcontext->theme, iPartId, iStateId, TMT_CONTENTALIGNMENT, &align);
128 if (align == CA_CENTER)
129 drawStyles |= DT_CENTER;
130 else if (align == CA_RIGHT)
131 drawStyles |= DT_RIGHT;
132
133 oldTextColor = SetTextColor(pcontext->hDC, textColor);
134 DrawThemeText(pcontext->theme,
135 pcontext->hDC,
136 iPartId,
137 iStateId,
138 pszText,
139 len - 1,
140 drawStyles,
141 0,
142 pRect);
143 SetTextColor(pcontext->hDC, oldTextColor);
144
145 if (hFont)
146 {
147 SelectObject(pcontext->hDC, oldFont);
149 }
150 if (pszText != buffer)
151 {
152 HeapFree(GetProcessHeap(), 0, pszText);
153 }
154 return S_OK;
155}
HFONT hFont
Definition: main.c:53
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
HRESULT WINAPI GetThemeEnumValue(HTHEME hTheme, int iPartId, int iStateId, int iPropId, int *piVal)
Definition: property.c:63
int align(int length, int align)
Definition: dsound8.c:36
GLuint buffer
Definition: glext.h:5915
HRESULT hr
Definition: shlfolder.c:183
@ CA_RIGHT
Definition: vssym32.h:65
@ CA_CENTER
Definition: vssym32.h:64
@ CA_LEFT
Definition: vssym32.h:63
#define TMT_CAPTIONFONT
Definition: vssym32.h:164
#define TMT_CONTENTALIGNMENT
Definition: vssym32.h:358
DWORD COLORREF
Definition: windef.h:300
#define COLOR_INACTIVECAPTIONTEXT
Definition: winuser.h:934
#define DT_END_ELLIPSIS
Definition: winuser.h:529
#define DT_RIGHT
Definition: winuser.h:538
INT WINAPI InternalGetWindowText(_In_ HWND hWnd, _Out_writes_to_(cchMaxCount, return+1) LPWSTR pString, _In_ int cchMaxCount)
#define COLOR_CAPTIONTEXT
Definition: winuser.h:922

Referenced by ThemeDrawCaption().

◆ ThemeDrawMenuBar()

static void ThemeDrawMenuBar ( PDRAW_CONTEXT  pcontext,
RECT prcCurrent 
)
static

Definition at line 524 of file nonclient.c.

525{
526 /* Let the window manager paint the menu */
527 prcCurrent->top += PaintMenuBar(pcontext->hWnd,
528 pcontext->hDC,
529 pcontext->wi.cxWindowBorders,
530 pcontext->wi.cxWindowBorders,
531 prcCurrent->top,
532 pcontext->Active);
533}
BOOL WINAPI PaintMenuBar(HWND hWnd, HDC hDC, ULONG left, ULONG right, ULONG top, BOOL bActive)

Referenced by ThemePaintWindow().

◆ ThemeDrawScrollBarsGrip()

static void ThemeDrawScrollBarsGrip ( PDRAW_CONTEXT  pcontext,
RECT prcCurrent 
)
static

Definition at line 535 of file nonclient.c.

536{
537 RECT rcPart;
539 RECT ParentClientRect;
540 DWORD ParentStyle;
541
542 rcPart = *prcCurrent;
543
544 if (pcontext->wi.dwExStyle & WS_EX_LEFTSCROLLBAR)
545 rcPart.right = rcPart.left + GetSystemMetrics(SM_CXVSCROLL);
546 else
547 rcPart.left = rcPart.right - GetSystemMetrics(SM_CXVSCROLL);
548
549 rcPart.top = rcPart.bottom - GetSystemMetrics(SM_CYHSCROLL);
550
551 FillRect(pcontext->hDC, &rcPart, GetSysColorBrush(COLOR_BTNFACE));
552
553 hwndParent = GetParent(pcontext->hWnd);
554 GetClientRect(hwndParent, &ParentClientRect);
555 ParentStyle = GetWindowLongW(hwndParent, GWL_STYLE);
556
557 if (HASSIZEGRIP(pcontext->wi.dwStyle, pcontext->wi.dwExStyle, ParentStyle, pcontext->wi.rcWindow, ParentClientRect))
558 {
559 int iState;
560 if (pcontext->wi.dwExStyle & WS_EX_LEFTSCROLLBAR)
561 iState = pcontext->wi.dwExStyle & WS_EX_LEFTSCROLLBAR;
562 else
563 iState = SZB_RIGHTALIGN;
564 DrawThemeBackground(pcontext->scrolltheme, pcontext->hDC, SBP_SIZEBOX, iState, &rcPart, NULL);
565 }
566}
static HWND hwndParent
Definition: cryptui.c:300
HTHEME scrolltheme
Definition: uxthemep.h:194
@ SZB_RIGHTALIGN
Definition: vsstyle.h:1122
@ SBP_SIZEBOX
Definition: vsstyle.h:1085
#define COLOR_BTNFACE
Definition: winuser.h:928

Referenced by ThemePaintWindow().

◆ ThemeEndBufferedPaint()

static void ThemeEndBufferedPaint ( PDRAW_CONTEXT  pcontext,
int  x,
int  y,
int  cx,
int  cy 
)
static

Definition at line 204 of file nonclient.c.

205{
207 BitBlt(pcontext->hDCScreen, 0, 0, cx, cy, pcontext->hDC, x, y, SRCCOPY);
208 hbmp = (HBITMAP) SelectObject(pcontext->hDC, pcontext->hbmpOld);
209 DeleteObject(pcontext->hDC);
211
212 pcontext->hDC = pcontext->hDCScreen;
213}
HBITMAP hbmp
static VOID BitBlt(_In_ ULONG Left, _In_ ULONG Top, _In_ ULONG Width, _In_ ULONG Height, _In_reads_bytes_(Delta *Height) PUCHAR Buffer, _In_ ULONG BitsPerPixel, _In_ ULONG Delta)
Definition: common.c:57
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
static HBITMAP
Definition: button.c:44
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:586
_Out_opt_ int * cx
Definition: commctrl.h:585
HBITMAP hbmpOld
Definition: uxthemep.h:203
#define SRCCOPY
Definition: wingdi.h:333

Referenced by ThemePaintWindow().

◆ ThemeGetButtonState()

static DWORD ThemeGetButtonState ( DWORD  htCurrect,
DWORD  htHot,
DWORD  htDown,
BOOL  Active 
)
static

Definition at line 344 of file nonclient.c.

345{
346 if (htHot == htCurrect)
348 if (htDown == htCurrect)
350
352}
@ BUTTON_HOT
Definition: uxthemep.h:221
@ BUTTON_PRESSED
Definition: uxthemep.h:222
@ BUTTON_INACTIVE_HOT
Definition: uxthemep.h:225
@ BUTTON_INACTIVE_PRESSED
Definition: uxthemep.h:226
_In_ ULONG _In_ BOOLEAN Active
Definition: potypes.h:561

Referenced by ThemeDrawCaptionButtons().

◆ ThemeHandleButton()

static VOID ThemeHandleButton ( HWND  hWnd,
WPARAM  wParam 
)
static

Definition at line 722 of file nonclient.c.

723{
724 MSG Msg;
725 BOOL Pressed = TRUE;
726 WPARAM SCMsg, ht;
727 ULONG Style;
729 PWND_DATA pwndData;
730
732 if (!((Style & WS_CAPTION) && (Style & WS_SYSMENU)))
733 return ;
734
735 switch (wParam)
736 {
737 case HTCLOSE:
738 SCMsg = SC_CLOSE;
739 break;
740 case HTMINBUTTON:
741 if (!(Style & WS_MINIMIZEBOX))
742 return;
743 SCMsg = ((Style & WS_MINIMIZE) ? SC_RESTORE : SC_MINIMIZE);
744 break;
745 case HTMAXBUTTON:
746 if (!(Style & WS_MAXIMIZEBOX))
747 return;
748 SCMsg = ((Style & WS_MAXIMIZE) ? SC_RESTORE : SC_MAXIMIZE);
749 break;
750 default :
751 return;
752 }
753
754 /* Get theme data for this window */
755 pwndData = ThemeGetWndData(hWnd);
756 if (pwndData == NULL)
757 return;
758
761 pwndData->lastHitTest = wParam;
762
764
765 ht = wParam;
766
767 for (;;)
768 {
770 break;
771
772 if (Msg.message == WM_LBUTTONUP)
773 break;
774
775 if (Msg.message != WM_MOUSEMOVE)
776 continue;
777
778 ht = SendMessage(hWnd, WM_NCHITTEST, 0, MAKELPARAM(Msg.pt.x, Msg.pt.y));
779 Pressed = (ht == wParam);
780
781 /* Only draw the buttons if the hit test changed */
782 if (ht != pwndData->lastHitTest &&
783 (HT_ISBUTTON(ht) || HT_ISBUTTON(pwndData->lastHitTest)))
784 {
785 ThemeDrawCaptionButtons(&context, 0, Pressed ? wParam: 0);
786 pwndData->lastHitTest = ht;
787 }
788 }
789
792
794
795 if (Pressed)
796 SendMessageW(hWnd, WM_SYSCOMMAND, SCMsg, 0);
797}
const DWORD Style
Definition: appswitch.c:71
return
Definition: dirsup.c:529
struct @1632 Msg[]
WPARAM wParam
Definition: combotst.c:138
static void ThemeDrawCaptionButtons(PDRAW_CONTEXT pcontext, DWORD htHot, DWORD htDown)
Definition: nonclient.c:356
void ThemeInitDrawContext(PDRAW_CONTEXT pcontext, HWND hWnd, HRGN hRgn)
Definition: nonclient.c:158
static const struct newhuff ht[]
Definition: huffman.h:296
UINT lastHitTest
Definition: uxthemep.h:171
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
uint32_t ULONG
Definition: typedefs.h:59
#define HT_ISBUTTON(ht)
Definition: uxthemep.h:230
UINT_PTR WPARAM
Definition: windef.h:207
HWND WINAPI SetCapture(_In_ HWND hWnd)
#define WM_SYSCOMMAND
Definition: winuser.h:1741
#define WM_MOUSEFIRST
Definition: winuser.h:1774
#define MAKELPARAM(l, h)
Definition: winuser.h:4008
#define WM_MOUSELAST
Definition: winuser.h:1801
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2890
BOOL WINAPI GetMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT)
#define WM_NCHITTEST
Definition: winuser.h:1686
#define WM_MOUSEMOVE
Definition: winuser.h:1775
#define SC_MINIMIZE
Definition: winuser.h:2586
#define SendMessage
Definition: winuser.h:5843
#define WM_LBUTTONUP
Definition: winuser.h:1777
#define SC_RESTORE
Definition: winuser.h:2598
#define SC_MAXIMIZE
Definition: winuser.h:2588

Referenced by ThemeWndProc().

◆ ThemeHandleNcMouseLeave()

static LRESULT ThemeHandleNcMouseLeave ( HWND  hWnd)
static

Definition at line 688 of file nonclient.c.

689{
691 DWORD style;
692 PWND_DATA pwndData;
693
694 /* First of all check if we have something to do here */
697 return 0;
698
699 /* Get theme data for this window */
700 pwndData = ThemeGetWndData(hWnd);
701 if (pwndData == NULL)
702 return 0;
703
705 if (context.wi.dwStyle & WS_SYSMENU && HT_ISBUTTON(pwndData->lastHitTest))
707
708 if (context.wi.dwStyle & WS_HSCROLL && pwndData->lastHitTest == HTHSCROLL)
710
711 if (context.wi.dwStyle & WS_VSCROLL && pwndData->lastHitTest == HTVSCROLL)
713
715
716 pwndData->lastHitTest = HTNOWHERE;
717
718 return 0;
719}
void ThemeDrawScrollBar(PDRAW_CONTEXT pcontext, INT nBar, POINT *pt)
Definition: ncscrollbar.c:318
#define SB_HORZ
Definition: winuser.h:552

Referenced by ThemeWndProc().

◆ ThemeHandleNcMouseMove()

static LRESULT ThemeHandleNcMouseMove ( HWND  hWnd,
DWORD  ht,
POINT pt 
)
static

Definition at line 633 of file nonclient.c.

634{
636 TRACKMOUSEEVENT tme;
637 DWORD style;
638 PWND_DATA pwndData;
639
640 /* First of all check if we have something to do here */
643 return 0;
644
645 /* Get theme data for this window */
646 pwndData = ThemeGetWndData(hWnd);
647 if (pwndData == NULL)
648 return 0;
649
650 /* Begin tracking in the non client area if we are not tracking yet */
651 tme.cbSize = sizeof(TRACKMOUSEEVENT);
652 tme.dwFlags = TME_QUERY;
653 tme.hwndTrack = hWnd;
654 TrackMouseEvent(&tme);
655 if (tme.dwFlags != (TME_LEAVE | TME_NONCLIENT))
656 {
657 tme.hwndTrack = hWnd;
659 TrackMouseEvent(&tme);
660 }
661
663 if (context.wi.dwStyle & WS_SYSMENU)
664 {
665 if (HT_ISBUTTON(ht) || HT_ISBUTTON(pwndData->lastHitTest))
667 }
668
669 if (context.wi.dwStyle & WS_HSCROLL)
670 {
671 if (ht == HTHSCROLL || pwndData->lastHitTest == HTHSCROLL)
673 }
674
675 if (context.wi.dwStyle & WS_VSCROLL)
676 {
677 if (ht == HTVSCROLL || pwndData->lastHitTest == HTVSCROLL)
679 }
681
682 pwndData->lastHitTest = ht;
683
684 return 0;
685}
#define TME_LEAVE
Definition: commctrl.h:4981
#define TME_NONCLIENT
Definition: commctrl.h:4982
struct tagTRACKMOUSEEVENT TRACKMOUSEEVENT
#define TME_QUERY
Definition: commctrl.h:4983
BOOL WINAPI TrackMouseEvent(_Inout_ LPTRACKMOUSEEVENT)

Referenced by ThemeWndProc().

◆ ThemeHandleNCPaint()

static LRESULT ThemeHandleNCPaint ( HWND  hWnd,
HRGN  hRgn 
)
static

Definition at line 616 of file nonclient.c.

617{
619 RECT rcCurrent;
620
622
623 rcCurrent = context.wi.rcWindow;
624 OffsetRect( &rcCurrent, -context.wi.rcWindow.left, -context.wi.rcWindow.top);
625
626 ThemePaintWindow(&context, &rcCurrent, TRUE);
628
629 return 0;
630}
static HRGN hRgn
Definition: mapping.c:33

Referenced by ThemeWndProc().

◆ ThemeInitDrawContext()

void ThemeInitDrawContext ( PDRAW_CONTEXT  pcontext,
HWND  hWnd,
HRGN  hRgn 
)

Definition at line 158 of file nonclient.c.

161{
162 pcontext->wi.cbSize = sizeof(pcontext->wi);
163 GetWindowInfo(hWnd, &pcontext->wi);
164 pcontext->hWnd = hWnd;
165 pcontext->Active = IsWindowActive(hWnd, pcontext->wi.dwExStyle);
166 pcontext->theme = GetNCCaptionTheme(hWnd, pcontext->wi.dwStyle);
167 pcontext->scrolltheme = GetNCScrollbarTheme(hWnd, pcontext->wi.dwStyle);
168
169 pcontext->CaptionHeight = pcontext->wi.cyWindowBorders;
171
172 if (hRgn <= (HRGN)1)
173 {
175 }
176 pcontext->hRgn = hRgn;
177
179}
#define DCX_USESTYLE
Definition: GetDCEx.c:10
static BOOL IsWindowActive(HWND hWnd, DWORD ExStyle)
Definition: nonclient.c:16
HTHEME GetNCScrollbarTheme(HWND hWnd, DWORD style)
Definition: themehooks.c:118
#define DCX_KEEPCLIPRGN
Definition: undocuser.h:68
#define DCX_WINDOW
Definition: winuser.h:2113
HDC WINAPI GetDCEx(_In_opt_ HWND, _In_opt_ HRGN, _In_ DWORD)
#define DCX_INTERSECTRGN
Definition: winuser.h:2122

Referenced by SCROLL_HandleScrollEvent(), ThemeHandleButton(), ThemeHandleNcMouseLeave(), ThemeHandleNcMouseMove(), and ThemeHandleNCPaint().

◆ ThemePaintWindow()

static void ThemePaintWindow ( PDRAW_CONTEXT  pcontext,
RECT prcCurrent,
BOOL  bDoDoubleBuffering 
)
static

Definition at line 569 of file nonclient.c.

570{
571 if (!(pcontext->wi.dwStyle & WS_VISIBLE))
572 return;
573
574 if ((pcontext->wi.dwStyle & WS_CAPTION)==WS_CAPTION)
575 {
576 if (bDoDoubleBuffering)
577 ThemeStartBufferedPaint(pcontext, prcCurrent->right, pcontext->CaptionHeight);
578 ThemeDrawCaption(pcontext, prcCurrent);
579 if (bDoDoubleBuffering)
580 ThemeEndBufferedPaint(pcontext, 0, 0, prcCurrent->right, pcontext->CaptionHeight);
581 ThemeDrawBorders(pcontext, prcCurrent);
582 }
583 else
584 {
585 DrawClassicFrame(pcontext, prcCurrent);
586 }
587
588 if (pcontext->wi.dwStyle & WS_MINIMIZE)
589 return;
590
591 if (HAS_MENU(pcontext->hWnd, pcontext->wi.dwStyle))
592 ThemeDrawMenuBar(pcontext, prcCurrent);
593
594 if (pcontext->wi.dwExStyle & WS_EX_CLIENTEDGE)
595 DrawEdge(pcontext->hDC, prcCurrent, EDGE_SUNKEN, BF_RECT | BF_ADJUST);
596
597 if ((pcontext->wi.dwStyle & WS_HSCROLL) && IsScrollBarVisible(pcontext->hWnd, OBJID_HSCROLL))
598 ThemeDrawScrollBar(pcontext, SB_HORZ , NULL);
599
600 if ((pcontext->wi.dwStyle & WS_VSCROLL) && IsScrollBarVisible(pcontext->hWnd, OBJID_VSCROLL))
601 ThemeDrawScrollBar(pcontext, SB_VERT, NULL);
602
603 if ((pcontext->wi.dwStyle & (WS_HSCROLL|WS_VSCROLL)) == (WS_HSCROLL|WS_VSCROLL) &&
606 {
607 ThemeDrawScrollBarsGrip(pcontext, prcCurrent);
608 }
609}
static void ThemeDrawScrollBarsGrip(PDRAW_CONTEXT pcontext, RECT *prcCurrent)
Definition: nonclient.c:535
static void ThemeStartBufferedPaint(PDRAW_CONTEXT pcontext, int cx, int cy)
Definition: nonclient.c:193
static void ThemeDrawCaption(PDRAW_CONTEXT pcontext, RECT *prcCurrent)
Definition: nonclient.c:371
static void ThemeDrawBorders(PDRAW_CONTEXT pcontext, RECT *prcCurrent)
Definition: nonclient.c:435
static void DrawClassicFrame(PDRAW_CONTEXT context, RECT *prcCurrent)
Definition: nonclient.c:460
static void ThemeEndBufferedPaint(PDRAW_CONTEXT pcontext, int x, int y, int cx, int cy)
Definition: nonclient.c:204
static void ThemeDrawMenuBar(PDRAW_CONTEXT pcontext, RECT *prcCurrent)
Definition: nonclient.c:524
#define HAS_MENU(hwnd, style)
Definition: uxthemep.h:238
#define OBJID_HSCROLL
Definition: winable.h:21
#define EDGE_SUNKEN
Definition: winuser.h:451

Referenced by DrawWindowForNCPreview(), and ThemeHandleNCPaint().

◆ ThemeStartBufferedPaint()

static void ThemeStartBufferedPaint ( PDRAW_CONTEXT  pcontext,
int  cx,
int  cy 
)
static

Definition at line 193 of file nonclient.c.

194{
196
197 pcontext->hDCScreen = pcontext->hDC;
198 pcontext->hDC = CreateCompatibleDC(pcontext->hDCScreen);
200 pcontext->hbmpOld = (HBITMAP)SelectObject(pcontext->hDC, hbmp);
201}
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
HBITMAP WINAPI CreateCompatibleBitmap(_In_ HDC hdc, _In_ INT cx, _In_ INT cy)

Referenced by ThemePaintWindow().

◆ ThemeWndProc()

LRESULT CALLBACK ThemeWndProc ( HWND  hWnd,
UINT  Msg,
WPARAM  wParam,
LPARAM  lParam,
WNDPROC  DefWndProc 
)

Definition at line 1015 of file nonclient.c.

1016{
1017 switch(Msg)
1018 {
1019 case WM_NCPAINT:
1020 return ThemeHandleNCPaint(hWnd, (HRGN)wParam);
1021 //
1022 // WM_NCUAHDRAWCAPTION : wParam are DC_* flags.
1023 //
1025 //
1026 // WM_NCUAHDRAWFRAME : wParam is HDC, lParam are DC_ACTIVE and or DC_REDRAWHUNGWND.
1027 //
1028 case WM_NCUAHDRAWFRAME:
1029 case WM_NCACTIVATE:
1030
1032 return TRUE;
1033
1034 ThemeHandleNCPaint(hWnd, (HRGN)1);
1035 return TRUE;
1036 case WM_NCMOUSEMOVE:
1037 {
1038 POINT Point;
1042 }
1043 case WM_NCMOUSELEAVE:
1045 case WM_NCLBUTTONDOWN:
1046 switch (wParam)
1047 {
1048 case HTMINBUTTON:
1049 case HTMAXBUTTON:
1050 case HTCLOSE:
1051 {
1053 return 0;
1054 }
1055 default:
1056 return DefWndProc(hWnd, Msg, wParam, lParam);
1057 }
1058 case WM_NCHITTEST:
1059 {
1060 POINT Point;
1063 return DefWndNCHitTest(hWnd, Point);
1064 }
1065 case WM_SYSCOMMAND:
1066 {
1067 if ((wParam & 0xfff0) == SC_VSCROLL ||
1068 (wParam & 0xfff0) == SC_HSCROLL)
1069 {
1070 POINT Pt;
1071 Pt.x = (short)LOWORD(lParam);
1072 Pt.y = (short)HIWORD(lParam);
1074 return 0;
1075 }
1076 else
1077 {
1078 return DefWndProc(hWnd, Msg, wParam, lParam);
1079 }
1080 }
1081 default:
1082 return DefWndProc(hWnd, Msg, wParam, lParam);
1083 }
1084}
LPARAM lParam
Definition: combotst.c:139
static VOID ThemeHandleButton(HWND hWnd, WPARAM wParam)
Definition: nonclient.c:722
static LRESULT ThemeHandleNcMouseLeave(HWND hWnd)
Definition: nonclient.c:688
static LRESULT ThemeHandleNCPaint(HWND hWnd, HRGN hRgn)
Definition: nonclient.c:616
static LRESULT ThemeHandleNcMouseMove(HWND hWnd, DWORD ht, POINT *pt)
Definition: nonclient.c:633
static LRESULT DefWndNCHitTest(HWND hWnd, POINT Point)
Definition: nonclient.c:800
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:94
void NC_TrackScrollBar(HWND hwnd, WPARAM wParam, POINT pt)
Definition: ncscrollbar.c:674
#define LOWORD(l)
Definition: pedump.c:82
long x
Definition: polytest.cpp:48
#define HIWORD(l)
Definition: typedefs.h:247
#define WM_NCUAHDRAWCAPTION
Definition: undocuser.h:46
#define WM_NCUAHDRAWFRAME
Definition: undocuser.h:47
#define GET_Y_LPARAM(lp)
Definition: windowsx.h:300
#define GET_X_LPARAM(lp)
Definition: windowsx.h:299
#define SC_HSCROLL
Definition: winuser.h:2594
#define SC_VSCROLL
Definition: winuser.h:2593
#define WM_NCMOUSEMOVE
Definition: winuser.h:1691
#define WM_NCACTIVATE
Definition: winuser.h:1688
#define WM_NCMOUSELEAVE
Definition: winuser.h:1842
#define WM_NCLBUTTONDOWN
Definition: winuser.h:1692
#define WM_NCPAINT
Definition: winuser.h:1687

Referenced by ThemeDefWindowProcA(), and ThemeDefWindowProcW().

◆ UserGetWindowIcon()

static HICON UserGetWindowIcon ( PDRAW_CONTEXT  pcontext)
static

Definition at line 63 of file nonclient.c.

64{
66
67 SendMessageTimeout(pcontext->hWnd, WM_GETICON, ICON_SMALL2, 0, SMTO_ABORTIFHUNG, 1000, (PDWORD_PTR)&hIcon);
68
69 if (!hIcon)
70 SendMessageTimeout(pcontext->hWnd, WM_GETICON, ICON_SMALL, 0, SMTO_ABORTIFHUNG, 1000, (PDWORD_PTR)&hIcon);
71
72 if (!hIcon)
73 SendMessageTimeout(pcontext->hWnd, WM_GETICON, ICON_BIG, 0, SMTO_ABORTIFHUNG, 1000, (PDWORD_PTR)&hIcon);
74
75 if (!hIcon)
77
78 if (!hIcon)
80
81 // See also win32ss/user/ntuser/nonclient.c!NC_IconForWindow
82 if (!hIcon && !(pcontext->wi.dwExStyle & WS_EX_DLGMODALFRAME))
84
85 return hIcon;
86}
ULONG_PTR * PDWORD_PTR
Definition: basetsd.h:182
#define ICON_BIG
Definition: tnclass.cpp:51
#define ICON_SMALL
Definition: tnclass.cpp:48
#define SendMessageTimeout
Definition: winuser.h:5845
#define GCLP_HICONSM
Definition: winuser.h:675
#define GCLP_HICON
Definition: winuser.h:674
#define GetClassLongPtr
Definition: winuser.h:5782
#define IDI_WINLOGO
Definition: winuser.h:709
#define SMTO_ABORTIFHUNG
Definition: winuser.h:1223
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE hInstance, _In_ LPCWSTR lpIconName)
Definition: cursoricon.c:2075
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by ThemeDrawCaption().

◆ UserHasWindowEdge()

static BOOL UserHasWindowEdge ( DWORD  Style,
DWORD  ExStyle 
)
static

Definition at line 46 of file nonclient.c.

47{
48 if (Style & WS_MINIMIZE)
49 return TRUE;
51 return TRUE;
53 return FALSE;
54 if (Style & WS_THICKFRAME)
55 return TRUE;
57 if (Style == WS_DLGFRAME || Style == WS_CAPTION)
58 return TRUE;
59 return FALSE;
60}

Referenced by DefWndNCHitTest(), DrawClassicFrame(), NC_DoNCPaint(), NC_HandleNCCalcSize(), UserDrawCaptionBar(), and UserGetWindowBorders().