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

Go to the source code of this file.

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)
 
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)
 
HRESULT WINAPI DrawNCPreview (HDC hDC, DWORD DNCP_Flag, LPRECT prcPreview, LPCWSTR pszThemeFileName, LPCWSTR pszColorName, LPCWSTR pszSizeName, PNONCLIENTMETRICSW pncMetrics, COLORREF *lpaRgbValues)
 

Function Documentation

◆ DefWndNCHitTest()

static LRESULT DefWndNCHitTest ( HWND  hWnd,
POINT  Point 
)
static

Definition at line 792 of file nonclient.c.

793 {
794  RECT WindowRect;
795  POINT ClientPoint;
796  WINDOWINFO wi;
797 
798  wi.cbSize = sizeof(wi);
799  GetWindowInfo(hWnd, &wi);
800 
801  if (!PtInRect(&wi.rcWindow, Point))
802  {
803  return HTNOWHERE;
804  }
805  WindowRect = wi.rcWindow;
806 
807  if (UserHasWindowEdge(wi.dwStyle, wi.dwExStyle))
808  {
809  LONG XSize, YSize;
810 
811  InflateRect(&WindowRect, -(int)wi.cxWindowBorders, -(int)wi.cyWindowBorders);
814  if (!PtInRect(&WindowRect, Point))
815  {
816  BOOL ThickFrame;
817 
818  ThickFrame = (wi.dwStyle & WS_THICKFRAME);
819  if (Point.y < WindowRect.top)
820  {
821  if(wi.dwStyle & WS_MINIMIZE)
822  return HTCAPTION;
823  if(!ThickFrame)
824  return HTBORDER;
825  if (Point.x < (WindowRect.left + XSize))
826  return HTTOPLEFT;
827  if (Point.x >= (WindowRect.right - XSize))
828  return HTTOPRIGHT;
829  return HTTOP;
830  }
831  if (Point.y >= WindowRect.bottom)
832  {
833  if(wi.dwStyle & WS_MINIMIZE)
834  return HTCAPTION;
835  if(!ThickFrame)
836  return HTBORDER;
837  if (Point.x < (WindowRect.left + XSize))
838  return HTBOTTOMLEFT;
839  if (Point.x >= (WindowRect.right - XSize))
840  return HTBOTTOMRIGHT;
841  return HTBOTTOM;
842  }
843  if (Point.x < WindowRect.left)
844  {
845  if(wi.dwStyle & WS_MINIMIZE)
846  return HTCAPTION;
847  if(!ThickFrame)
848  return HTBORDER;
849  if (Point.y < (WindowRect.top + YSize))
850  return HTTOPLEFT;
851  if (Point.y >= (WindowRect.bottom - YSize))
852  return HTBOTTOMLEFT;
853  return HTLEFT;
854  }
855  if (Point.x >= WindowRect.right)
856  {
857  if(wi.dwStyle & WS_MINIMIZE)
858  return HTCAPTION;
859  if(!ThickFrame)
860  return HTBORDER;
861  if (Point.y < (WindowRect.top + YSize))
862  return HTTOPRIGHT;
863  if (Point.y >= (WindowRect.bottom - YSize))
864  return HTBOTTOMRIGHT;
865  return HTRIGHT;
866  }
867  }
868  }
869  else
870  {
871  if (wi.dwExStyle & WS_EX_STATICEDGE)
874  if (!PtInRect(&WindowRect, Point))
875  return HTBORDER;
876  }
877 
878  if ((wi.dwStyle & WS_CAPTION) == WS_CAPTION)
879  {
880  if (wi.dwExStyle & WS_EX_TOOLWINDOW)
881  WindowRect.top += GetSystemMetrics(SM_CYSMCAPTION);
882  else
883  WindowRect.top += GetSystemMetrics(SM_CYCAPTION);
884 
885  if (!PtInRect(&WindowRect, Point))
886  {
887  if (wi.dwStyle & WS_SYSMENU)
888  {
889  PWND_DATA pwndData = ThemeGetWndData(hWnd);
890 
891  if (!(wi.dwExStyle & WS_EX_TOOLWINDOW))
892  {
893  // if(!(wi.dwExStyle & WS_EX_DLGMODALFRAME))
894  // FIXME: The real test should check whether there is
895  // an icon for the system window, and if so, do the
896  // rect.left increase.
897  // See win32ss/user/user32/windows/nonclient.c!DefWndNCHitTest
898  // and win32ss/user/ntuser/nonclient.c!GetNCHitEx which does
899  // the test better.
900  WindowRect.left += GetSystemMetrics(SM_CXSMICON);
901  }
902 
903  if (pwndData)
904  {
905  POINT pt = {Point.x - wi.rcWindow.left, Point.y - wi.rcWindow.top};
906  if (PtInRect(&pwndData->rcCaptionButtons[CLOSEBUTTON], pt))
907  return HTCLOSE;
908  if (PtInRect(&pwndData->rcCaptionButtons[MAXBUTTON], pt))
909  return HTMAXBUTTON;
910  if (PtInRect(&pwndData->rcCaptionButtons[MINBUTTON], pt))
911  return HTMINBUTTON;
912  }
913  }
914  if (Point.x < WindowRect.left)
915  return HTSYSMENU;
916  return HTCAPTION;
917  }
918  }
919 
920  if(!(wi.dwStyle & WS_MINIMIZE))
921  {
922  HMENU menu;
923 
924  ClientPoint = Point;
925  ScreenToClient(hWnd, &ClientPoint);
927 
928  if (PtInRect(&wi.rcClient, ClientPoint))
929  {
930  return HTCLIENT;
931  }
932 
933  if ((menu = GetMenu(hWnd)) && !(wi.dwStyle & WS_CHILD))
934  {
935  if (Point.x > 0 && Point.x < WindowRect.right && ClientPoint.y < 0)
936  return HTMENU;
937  }
938 
939  if (wi.dwExStyle & WS_EX_CLIENTEDGE)
940  {
941  InflateRect(&WindowRect, -2 * GetSystemMetrics(SM_CXBORDER),
943  }
944 
945  if ((wi.dwStyle & WS_VSCROLL) && (wi.dwStyle & WS_HSCROLL) &&
946  (WindowRect.bottom - WindowRect.top) > GetSystemMetrics(SM_CYHSCROLL))
947  {
948  RECT ParentRect, TempRect = WindowRect, TempRect2 = WindowRect;
950 
951  TempRect.bottom -= GetSystemMetrics(SM_CYHSCROLL);
952  if ((wi.dwExStyle & WS_EX_LEFTSCROLLBAR) != 0)
953  TempRect.right = TempRect.left + GetSystemMetrics(SM_CXVSCROLL);
954  else
955  TempRect.left = TempRect.right - GetSystemMetrics(SM_CXVSCROLL);
956  if (PtInRect(&TempRect, Point))
957  return HTVSCROLL;
958 
959  TempRect2.top = TempRect2.bottom - GetSystemMetrics(SM_CYHSCROLL);
960  if ((wi.dwExStyle & WS_EX_LEFTSCROLLBAR) != 0)
961  TempRect2.left += GetSystemMetrics(SM_CXVSCROLL);
962  else
963  TempRect2.right -= GetSystemMetrics(SM_CXVSCROLL);
964  if (PtInRect(&TempRect2, Point))
965  return HTHSCROLL;
966 
967  TempRect.top = TempRect2.top;
968  TempRect.bottom = TempRect2.bottom;
969  if(Parent)
970  GetClientRect(Parent, &ParentRect);
971  if (PtInRect(&TempRect, Point) && HASSIZEGRIP(wi.dwStyle, wi.dwExStyle,
972  GetWindowLongW(Parent, GWL_STYLE), wi.rcWindow, ParentRect))
973  {
974  if ((wi.dwExStyle & WS_EX_LEFTSCROLLBAR) != 0)
975  return HTBOTTOMLEFT;
976  else
977  return HTBOTTOMRIGHT;
978  }
979  }
980  else
981  {
982  if (wi.dwStyle & WS_VSCROLL)
983  {
984  RECT TempRect = WindowRect;
985 
986  if ((wi.dwExStyle & WS_EX_LEFTSCROLLBAR) != 0)
987  TempRect.right = TempRect.left + GetSystemMetrics(SM_CXVSCROLL);
988  else
989  TempRect.left = TempRect.right - GetSystemMetrics(SM_CXVSCROLL);
990  if (PtInRect(&TempRect, Point))
991  return HTVSCROLL;
992  }
993  else if (wi.dwStyle & WS_HSCROLL)
994  {
995  RECT TempRect = WindowRect;
996  TempRect.top = TempRect.bottom - GetSystemMetrics(SM_CYHSCROLL);
997  if (PtInRect(&TempRect, Point))
998  return HTHSCROLL;
999  }
1000  }
1001  }
1002 
1003  return HTNOWHERE;
1004 }
#define HTMAXBUTTON
Definition: winuser.h:2459
#define HTTOP
Definition: winuser.h:2465
#define WS_THICKFRAME
Definition: pedump.c:630
#define HTLEFT
Definition: winuser.h:2462
BOOL WINAPI InflateRect(_Inout_ LPRECT, _In_ int, _In_ int)
#define HTHSCROLL
Definition: winuser.h:2456
#define SM_CYHSCROLL
Definition: winuser.h:952
DWORD cbSize
Definition: winuser.h:3741
#define SM_CYSIZE
Definition: winuser.h:982
long y
Definition: polytest.cpp:48
#define pt(x, y)
Definition: drawing.c:79
DWORD dwStyle
Definition: winuser.h:3744
UINT cxWindowBorders
Definition: winuser.h:3747
HWND hWnd
Definition: settings.c:17
LONG top
Definition: windef.h:307
UINT cyWindowBorders
Definition: winuser.h:3748
#define HTBOTTOMLEFT
Definition: winuser.h:2469
#define HTRIGHT
Definition: winuser.h:2464
#define WS_CHILD
Definition: pedump.c:617
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn BOOLEAN Physical 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:728
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
#define WS_EX_LEFTSCROLLBAR
Definition: winuser.h:392
#define HTNOWHERE
Definition: winuser.h:2449
#define WS_EX_TOOLWINDOW
Definition: winuser.h:404
#define HTMINBUTTON
Definition: winuser.h:2458
#define HTTOPLEFT
Definition: winuser.h:2466
static BOOL UserHasWindowEdge(DWORD Style, DWORD ExStyle)
Definition: nonclient.c:41
#define HTSYSMENU
Definition: winuser.h:2452
#define WS_MINIMIZE
Definition: pedump.c:622
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
RECT rcWindow
Definition: winuser.h:3742
#define WS_CAPTION
Definition: pedump.c:624
DWORD dwExStyle
Definition: winuser.h:3745
#define HTTOPRIGHT
Definition: winuser.h:2467
#define SM_CYCAPTION
Definition: winuser.h:953
int WINAPI GetSystemMetrics(_In_ int)
#define HTBOTTOM
Definition: winuser.h:2468
#define WS_HSCROLL
Definition: pedump.c:628
#define SM_CXSMICON
Definition: winuser.h:1002
#define HTCLOSE
Definition: winuser.h:2474
#define SM_CYBORDER
Definition: winuser.h:955
struct Point Point
#define SM_CXBORDER
Definition: winuser.h:954
#define HTBOTTOMRIGHT
Definition: winuser.h:2470
#define HTCAPTION
Definition: winuser.h:2451
#define GWL_STYLE
Definition: winuser.h:846
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
HWND WINAPI GetParent(_In_ HWND)
RECT rcCaptionButtons[4]
Definition: uxthemep.h:154
BOOL WINAPI GetWindowInfo(_In_ HWND, _Inout_ PWINDOWINFO)
#define WS_EX_CLIENTEDGE
Definition: winuser.h:384
#define HTMENU
Definition: winuser.h:2455
#define HTBORDER
Definition: winuser.h:2472
#define WS_VSCROLL
Definition: pedump.c:627
#define SM_CXVSCROLL
Definition: winuser.h:951
#define HTVSCROLL
Definition: winuser.h:2457
BOOL WINAPI PtInRect(_In_ LPCRECT, _In_ POINT)
#define SM_CXSIZE
Definition: winuser.h:981
#define HASSIZEGRIP(Style, ExStyle, ParentStyle, WindowRect, ParentClientRect)
Definition: nonclient.c:34
LONG bottom
Definition: windef.h:309
PWND_DATA ThemeGetWndData(HWND hWnd)
Definition: themehooks.c:17
RECT rcClient
Definition: winuser.h:3743
#define HTCLIENT
Definition: winuser.h:2450
BOOL WINAPI ScreenToClient(_In_ HWND, _Inout_ LPPOINT)
#define WS_SYSMENU
Definition: pedump.c:629
HMENU WINAPI GetMenu(_In_ HWND)
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
#define SM_CYSMCAPTION
Definition: winuser.h:1004
#define WS_EX_STATICEDGE
Definition: winuser.h:403

Referenced by ThemeWndProc().

◆ DrawClassicFrame()

static void DrawClassicFrame ( PDRAW_CONTEXT  context,
RECT prcCurrent 
)
static

Definition at line 451 of file nonclient.c.

452 {
453  /* Draw outer edge */
454  if (UserHasWindowEdge(context->wi.dwStyle, context->wi.dwExStyle))
455  {
456  DrawEdge(context->hDC, prcCurrent, EDGE_RAISED, BF_RECT | BF_ADJUST);
457  }
458  else if (context->wi.dwExStyle & WS_EX_STATICEDGE)
459  {
460  DrawEdge(context->hDC, prcCurrent, BDR_SUNKENINNER, BF_RECT | BF_ADJUST | BF_FLAT);
461  }
462 
463  /* Firstly the "thick" frame */
464  if ((context->wi.dwStyle & WS_THICKFRAME) && !(context->wi.dwStyle & WS_MINIMIZE))
465  {
466  INT Width =
469  INT Height =
472 
475 
476  /* Draw frame */
477  PatBlt(context->hDC, prcCurrent->left, prcCurrent->top,
478  prcCurrent->right - prcCurrent->left, Height, PATCOPY);
479  PatBlt(context->hDC, prcCurrent->left, prcCurrent->top,
480  Width, prcCurrent->bottom - prcCurrent->top, PATCOPY);
481  PatBlt(context->hDC, prcCurrent->left, prcCurrent->bottom - 1,
482  prcCurrent->right - prcCurrent->left, -Height, PATCOPY);
483  PatBlt(context->hDC, prcCurrent->right - 1, prcCurrent->top,
484  -Width, prcCurrent->bottom - prcCurrent->top, PATCOPY);
485 
486  InflateRect(prcCurrent, -Width, -Height);
487  }
488 
489  /* Now the other bit of the frame */
490  if (context->wi.dwStyle & (WS_DLGFRAME | WS_BORDER) || (context->wi.dwExStyle & WS_EX_DLGMODALFRAME))
491  {
493  INT Height = GetSystemMetrics(SM_CYBORDER);
494 
496  (context->wi.dwExStyle & (WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE)) ? COLOR_3DFACE :
497  (context->wi.dwExStyle & WS_EX_STATICEDGE) ? COLOR_WINDOWFRAME :
498  (context->wi.dwStyle & (WS_DLGFRAME | WS_THICKFRAME)) ? COLOR_3DFACE :
500 
501  /* Draw frame */
502  PatBlt(context->hDC, prcCurrent->left, prcCurrent->top,
503  prcCurrent->right - prcCurrent->left, Height, PATCOPY);
504  PatBlt(context->hDC, prcCurrent->left, prcCurrent->top,
505  Width, prcCurrent->bottom - prcCurrent->top, PATCOPY);
506  PatBlt(context->hDC, prcCurrent->left, prcCurrent->bottom - 1,
507  prcCurrent->right - prcCurrent->left, -Height, PATCOPY);
508  PatBlt(context->hDC, prcCurrent->right - 1, prcCurrent->top,
509  -Width, prcCurrent->bottom - prcCurrent->top, PATCOPY);
510 
511  InflateRect(prcCurrent, -Width, -Height);
512  }
513 }
#define BF_FLAT
Definition: winuser.h:471
#define WS_THICKFRAME
Definition: pedump.c:630
BOOL WINAPI InflateRect(_Inout_ LPRECT, _In_ int, _In_ int)
#define COLOR_WINDOWFRAME
Definition: winuser.h:909
Definition: http.c:7094
LONG top
Definition: windef.h:307
#define COLOR_INACTIVEBORDER
Definition: winuser.h:914
#define WS_DLGFRAME
Definition: pedump.c:626
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1499
LONG left
Definition: windef.h:306
#define SM_CYFRAME
Definition: winuser.h:986
#define SM_CXFRAME
Definition: winuser.h:984
LONG right
Definition: windef.h:308
int32_t INT
Definition: typedefs.h:58
#define BF_ADJUST
Definition: winuser.h:470
BOOL WINAPI PatBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
#define BF_RECT
Definition: winuser.h:462
static BOOL UserHasWindowEdge(DWORD Style, DWORD ExStyle)
Definition: nonclient.c:41
#define COLOR_3DFACE
Definition: winuser.h:919
#define BDR_SUNKENINNER
Definition: winuser.h:445
#define WS_MINIMIZE
Definition: pedump.c:622
BOOL WINAPI DrawEdge(_In_ HDC, _Inout_ LPRECT, _In_ UINT, _In_ UINT)
#define SM_CYDLGFRAME
Definition: winuser.h:958
#define WS_EX_DLGMODALFRAME
Definition: pedump.c:645
#define SM_CXDLGFRAME
Definition: winuser.h:956
#define COLOR_ACTIVEBORDER
Definition: winuser.h:913
int WINAPI GetSystemMetrics(_In_ int)
#define SM_CYBORDER
Definition: winuser.h:955
#define SM_CXBORDER
Definition: winuser.h:954
#define PATCOPY
Definition: wingdi.h:334
#define EDGE_RAISED
Definition: winuser.h:450
#define WS_BORDER
Definition: pedump.c:625
#define WS_EX_CLIENTEDGE
Definition: winuser.h:384
LONG bottom
Definition: windef.h:309
HBRUSH WINAPI GetSysColorBrush(_In_ int)
#define WS_EX_STATICEDGE
Definition: winuser.h:403

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 1078 of file nonclient.c.

1086 {
1087  WNDCLASSEXW DummyPreviewWindowClass;
1088  HWND hwndDummy;
1089  HRESULT hres;
1090  HTHEMEFILE hThemeFile;
1092  RECT rcCurrent;
1093 
1094  /* FIXME: We also need to implement drawing the rest of the preview windows
1095  * and make use of the ncmetrics and colors passed as parameters */
1096 
1097  /* Create a dummy window that will be used to trick the paint funtions */
1098  memset(&DummyPreviewWindowClass, 0, sizeof(DummyPreviewWindowClass));
1099  DummyPreviewWindowClass.cbSize = sizeof(DummyPreviewWindowClass);
1100  DummyPreviewWindowClass.lpszClassName = L"DummyPreviewWindowClass";
1101  DummyPreviewWindowClass.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
1102  DummyPreviewWindowClass.hInstance = hDllInst;
1103  DummyPreviewWindowClass.lpfnWndProc = DefWindowProcW;
1104  if (!RegisterClassExW(&DummyPreviewWindowClass))
1105  return E_FAIL;
1106 
1107  hwndDummy = CreateWindowExW(0, L"DummyPreviewWindowClass", L"Active window", WS_OVERLAPPEDWINDOW,30,30,300,150,0,0,hDllInst,NULL);
1108  if (!hwndDummy)
1109  return E_FAIL;
1110 
1111  hres = OpenThemeFile(pszThemeFileName, pszColorName, pszSizeName, &hThemeFile,0);
1112  if (FAILED(hres))
1113  return hres;
1114 
1115  /* Initialize the special draw context for the preview */
1116  context.hDC = hDC;
1117  context.hWnd = hwndDummy;
1118  context.theme = OpenThemeDataFromFile(hThemeFile, hwndDummy, L"WINDOW", 0);
1119  if (!context.theme)
1120  return E_FAIL;
1121  context.scrolltheme = OpenThemeDataFromFile(hThemeFile, hwndDummy, L"SCROLLBAR", 0);
1122  if (!context.scrolltheme)
1123  return E_FAIL;
1124  context.Active = TRUE;
1125  context.wi.cbSize = sizeof(context.wi);
1126  if (!GetWindowInfo(hwndDummy, &context.wi))
1127  return E_FAIL;
1128  context.wi.dwStyle |= WS_VISIBLE;
1129  context.CaptionHeight = context.wi.cyWindowBorders;
1130  context.CaptionHeight += GetSystemMetrics(context.wi.dwExStyle & WS_EX_TOOLWINDOW ? SM_CYSMCAPTION : SM_CYCAPTION );
1131  context.hRgn = CreateRectRgnIndirect(&context.wi.rcWindow);
1132 
1133  /* Paint the window on the preview hDC */
1134  rcCurrent = context.wi.rcWindow;
1135  OffsetRect( &rcCurrent, -context.wi.rcWindow.left, -context.wi.rcWindow.top);
1136  SetViewportOrgEx(hDC, context.wi.rcWindow.left, context.wi.rcWindow.top, NULL);
1137  ThemeCalculateCaptionButtonsPos(hwndDummy, context.theme);
1138  ThemePaintWindow(&context, &rcCurrent, FALSE);
1139  SetViewportOrgEx(hDC, 0, 0, NULL);
1140 
1141  context.hDC = NULL;
1142  CloseThemeData (context.theme);
1143  CloseThemeData (context.scrolltheme);
1145 
1146  /* Cleanup */
1147  DestroyWindow(hwndDummy);
1148  UnregisterClassW(L"DummyPreviewWindowClass", hDllInst);
1149 
1150  return S_OK;
1151 }
BOOL WINAPI SetViewportOrgEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
Definition: coord.c:655
BOOL WINAPI OffsetRect(_Inout_ LPRECT, _In_ int, _In_ int)
BOOL WINAPI UnregisterClassW(_In_ LPCWSTR, HINSTANCE)
HINSTANCE hDllInst
Definition: system.c:45
Definition: http.c:7094
#define TRUE
Definition: types.h:120
void ThemeCleanupDrawContext(PDRAW_CONTEXT pcontext)
Definition: nonclient.c:180
HRGN WINAPI CreateRectRgnIndirect(_In_ LPCRECT)
#define E_FAIL
Definition: ddrawi.h:102
BOOL WINAPI DestroyWindow(_In_ HWND)
#define WS_EX_TOOLWINDOW
Definition: winuser.h:404
#define COLOR_WINDOW
Definition: winuser.h:908
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
static void ThemePaintWindow(PDRAW_CONTEXT pcontext, RECT *prcCurrent, BOOL bDoDoubleBuffering)
Definition: nonclient.c:560
ATOM WINAPI RegisterClassExW(_In_ CONST WNDCLASSEXW *)
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:416
LPCWSTR lpszClassName
Definition: winuser.h:3201
HRESULT hres
Definition: protocol.c:465
#define SM_CYCAPTION
Definition: winuser.h:953
HBRUSH hbrBackground
Definition: winuser.h:3199
LONG HRESULT
Definition: typedefs.h:79
UINT cbSize
Definition: winuser.h:3191
int WINAPI GetSystemMetrics(_In_ int)
void ThemeCalculateCaptionButtonsPos(HWND hWnd, HTHEME htheme)
Definition: nonclient.c:213
HINSTANCE hInstance
Definition: winuser.h:3196
static const WCHAR L[]
Definition: oid.c:1250
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)
WNDPROC lpfnWndProc
Definition: winuser.h:3193
static HDC hDC
Definition: 3dtext.c:33
#define S_OK
Definition: intsafe.h:51
BOOL WINAPI GetWindowInfo(_In_ HWND, _Inout_ PWINDOWINFO)
HRESULT WINAPI OpenThemeFile(LPCWSTR pszThemeFileName, LPCWSTR pszColorName, LPCWSTR pszSizeName, HTHEMEFILE *hThemeFile, DWORD unknown)
Definition: system.c:1101
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define WS_VISIBLE
Definition: pedump.c:620
#define memset(x, y, z)
Definition: compat.h:39
#define SM_CYSMCAPTION
Definition: winuser.h:1004
HTHEME WINAPI OpenThemeDataFromFile(HTHEMEFILE hThemeFile, HWND hwnd, LPCWSTR pszClassList, DWORD flags)
Definition: system.c:827
HRESULT WINAPI CloseThemeData(HTHEME hTheme)
Definition: system.c:950

Referenced by DrawThemePreview().

◆ IsScrollBarVisible()

BOOL IsScrollBarVisible ( HWND  hWnd,
INT  hBar 
)

Definition at line 31 of file nonclient.c.

32 {
33  SCROLLBARINFO sbi = {sizeof(SCROLLBARINFO)};
34  if(!GetScrollBarInfo(hWnd, hBar, &sbi))
35  return FALSE;
36 
37  return !(sbi.rgstate[0] & STATE_SYSTEM_OFFSCREEN);
38 }
#define STATE_SYSTEM_OFFSCREEN
Definition: winuser.h:2853
HWND hWnd
Definition: settings.c:17
#define FALSE
Definition: types.h:117
BOOL WINAPI GetScrollBarInfo(_In_ HWND, _In_ LONG, _Inout_ PSCROLLBARINFO)
DWORD rgstate[CCHILDREN_SCROLLBAR+1]
Definition: winuser.h:3729
struct tagSCROLLBARINFO SCROLLBARINFO

Referenced by ThemePaintWindow().

◆ IsWindowActive()

static BOOL IsWindowActive ( HWND  hWnd,
DWORD  ExStyle 
)
static

Definition at line 12 of file nonclient.c.

13 {
14  BOOL ret;
15 
16  if (ExStyle & WS_EX_MDICHILD)
17  {
19  if (ret)
21  }
22  else
23  {
24  ret = (GetForegroundWindow() == hWnd);
25  }
26 
27  return ret;
28 }
HWND hWnd
Definition: settings.c:17
HANDLE HWND
Definition: compat.h:19
#define WS_EX_MDICHILD
Definition: winuser.h:394
unsigned int BOOL
Definition: ntddk_ex.h:94
#define WM_MDIGETACTIVE
Definition: winuser.h:1803
int ret
HWND WINAPI GetParent(_In_ HWND)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
HWND WINAPI GetForegroundWindow(void)
Definition: ntwrapper.h:392
BOOL WINAPI IsChild(_In_ HWND, _In_ HWND)
const DWORD ExStyle
Definition: appswitch.c:72

Referenced by ThemeInitDrawContext().

◆ ThemeCalculateCaptionButtonsPos()

void ThemeCalculateCaptionButtonsPos ( HWND  hWnd,
HTHEME  htheme 
)

Definition at line 213 of file nonclient.c.

214 {
215  PWND_DATA pwndData;
216  DWORD style;
217  INT ButtonWidth, ButtonHeight, iPartId, i;
218  WINDOWINFO wi = {sizeof(wi)};
219  RECT rcCurrent;
220  SIZE ButtonSize;
221 
222  /* First of all check if we have something to do here */
224  if((style & (WS_CAPTION | WS_SYSMENU)) != (WS_CAPTION | WS_SYSMENU))
225  return;
226 
227  /* Get theme data for this window */
228  pwndData = ThemeGetWndData(hWnd);
229  if (pwndData == NULL)
230  return;
231 
232  if (!htheme)
233  {
234  htheme = GetNCCaptionTheme(hWnd, style);
235  if (!htheme)
236  return;
237  }
238 
239  if(!GetWindowInfo(hWnd, &wi))
240  return;
241 
242  /* Calculate the area of the caption */
243  rcCurrent.top = rcCurrent.left = 0;
244  rcCurrent.right = wi.rcWindow.right - wi.rcWindow.left;
245  rcCurrent.bottom = wi.rcWindow.bottom - wi.rcWindow.top;
246 
247  /* Add a padding around the objects of the caption */
248  InflateRect(&rcCurrent, -(int)wi.cyWindowBorders-BUTTON_GAP_SIZE,
250 
252 
253  GetThemePartSize(htheme, NULL, iPartId, 0, NULL, TS_MIN, &ButtonSize);
254 
256  ButtonWidth = MulDiv(ButtonSize.cx, ButtonHeight, ButtonSize.cy);
257 
258  ButtonHeight -= 4;
259  ButtonWidth -= 4;
260 
261  for (i = CLOSEBUTTON; i <= HELPBUTTON; i++)
262  {
263  SetRect(&pwndData->rcCaptionButtons[i],
264  rcCurrent.right - ButtonWidth,
265  rcCurrent.top,
266  rcCurrent.right,
267  rcCurrent.top + ButtonHeight);
268 
269  rcCurrent.right -= ButtonWidth + BUTTON_GAP_SIZE;
270  }
271 }
HRESULT WINAPI GetThemePartSize(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, RECT *prc, THEMESIZE eSize, SIZE *psz)
Definition: draw.c:1777
HTHEME GetNCCaptionTheme(HWND hWnd, DWORD style)
Definition: themehooks.c:88
BOOL WINAPI InflateRect(_Inout_ LPRECT, _In_ int, _In_ int)
#define SM_CYSIZE
Definition: winuser.h:982
HWND hWnd
Definition: settings.c:17
LONG top
Definition: windef.h:307
UINT cyWindowBorders
Definition: winuser.h:3748
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
#define WS_EX_TOOLWINDOW
Definition: winuser.h:404
int32_t INT
Definition: typedefs.h:58
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
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
smooth NULL
Definition: ftsmooth.c:416
LONG cx
Definition: windef.h:334
RECT rcWindow
Definition: winuser.h:3742
#define WS_CAPTION
Definition: pedump.c:624
#define SM_CYSMSIZE
Definition: winuser.h:1006
DWORD dwExStyle
Definition: winuser.h:3745
int WINAPI GetSystemMetrics(_In_ int)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define BUTTON_GAP_SIZE
Definition: uxthemep.h:224
#define GWL_STYLE
Definition: winuser.h:846
RECT rcCaptionButtons[4]
Definition: uxthemep.h:154
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
BOOL WINAPI GetWindowInfo(_In_ HWND, _Inout_ PWINDOWINFO)
LONG bottom
Definition: windef.h:309
PWND_DATA ThemeGetWndData(HWND hWnd)
Definition: themehooks.c:17
Arabic default style
Definition: afstyles.h:93
#define WS_SYSMENU
Definition: pedump.c:629
LONG cy
Definition: windef.h:335
#define MulDiv(x, y, z)
Definition: gdifloat.h:86

Referenced by DrawNCPreview(), and ThemePreWindowProc().

◆ ThemeCleanupDrawContext()

void ThemeCleanupDrawContext ( PDRAW_CONTEXT  pcontext)

Definition at line 180 of file nonclient.c.

181 {
182  ReleaseDC(pcontext->hWnd ,pcontext->hDC);
183 
184  if(pcontext->hRgn != NULL)
185  {
186  DeleteObject(pcontext->hRgn);
187  }
188 }
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
smooth NULL
Definition: ftsmooth.c:416

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

◆ ThemeDrawBorders()

static void ThemeDrawBorders ( PDRAW_CONTEXT  pcontext,
RECT prcCurrent 
)
static

Definition at line 426 of file nonclient.c.

427 {
428  RECT rcPart;
429  int iState = pcontext->Active ? FS_ACTIVE : FS_INACTIVE;
430 
431  /* Draw the bottom border */
432  rcPart = *prcCurrent;
433  rcPart.top = rcPart.bottom - pcontext->wi.cyWindowBorders;
434  prcCurrent->bottom = rcPart.top;
435  DrawThemeBackground(pcontext->theme, pcontext->hDC, WP_FRAMEBOTTOM, iState, &rcPart, NULL);
436 
437  /* Draw the left border */
438  rcPart = *prcCurrent;
439  rcPart.right = rcPart.left + pcontext->wi.cxWindowBorders ;
440  prcCurrent->left = rcPart.right;
441  DrawThemeBackground(pcontext->theme, pcontext->hDC,WP_FRAMELEFT, iState, &rcPart, NULL);
442 
443  /* Draw the right border */
444  rcPart = *prcCurrent;
445  rcPart.left = rcPart.right - pcontext->wi.cxWindowBorders;
446  prcCurrent->right = rcPart.left;
447  DrawThemeBackground(pcontext->theme, pcontext->hDC,WP_FRAMERIGHT, iState, &rcPart, NULL);
448 }
UINT cxWindowBorders
Definition: winuser.h:3747
LONG top
Definition: windef.h:307
UINT cyWindowBorders
Definition: winuser.h:3748
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
HRESULT WINAPI DrawThemeBackground(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, const RECT *pClipRect)
Definition: draw.c:128
smooth NULL
Definition: ftsmooth.c:416
WINDOWINFO wi
Definition: uxthemep.h:180
HTHEME theme
Definition: uxthemep.h:177
LONG bottom
Definition: windef.h:309

Referenced by ThemePaintWindow().

◆ ThemeDrawCaption()

static void ThemeDrawCaption ( PDRAW_CONTEXT  pcontext,
RECT prcCurrent 
)
static

Definition at line 362 of file nonclient.c.

363 {
364  RECT rcPart;
365  int iPart, iState;
366  HICON hIcon;
367 
368  // See also win32ss/user/ntuser/nonclient.c!UserDrawCaptionBar
369  // and win32ss/user/ntuser/nonclient.c!UserDrawCaption
370  if ((pcontext->wi.dwStyle & WS_SYSMENU) && !(pcontext->wi.dwExStyle & WS_EX_TOOLWINDOW))
371  hIcon = UserGetWindowIcon(pcontext);
372  else
373  hIcon = NULL;
374 
375  /* Get the caption part and state id */
376  if (pcontext->wi.dwStyle & WS_MINIMIZE)
377  iPart = WP_MINCAPTION;
378  else if (pcontext->wi.dwExStyle & WS_EX_TOOLWINDOW)
379  iPart = WP_SMALLCAPTION;
380  else if (pcontext->wi.dwStyle & WS_MAXIMIZE)
381  iPart = WP_MAXCAPTION;
382  else
383  iPart = WP_CAPTION;
384 
385  iState = pcontext->Active ? FS_ACTIVE : FS_INACTIVE;
386 
387  /* Draw the caption background */
388  rcPart = *prcCurrent;
389  rcPart.bottom = rcPart.top + pcontext->CaptionHeight;
390  prcCurrent->top = rcPart.bottom;
391  DrawThemeBackground(pcontext->theme, pcontext->hDC,iPart,iState,&rcPart,NULL);
392 
393  /* Add a padding around the objects of the caption */
394  InflateRect(&rcPart, -(int)pcontext->wi.cyWindowBorders-BUTTON_GAP_SIZE,
395  -(int)pcontext->wi.cyWindowBorders-BUTTON_GAP_SIZE);
396 
397  /* Draw the caption buttons */
398  if (pcontext->wi.dwStyle & WS_SYSMENU)
399  {
400  iState = pcontext->Active ? BUTTON_NORMAL : BUTTON_INACTIVE;
401 
402  ThemeDrawCaptionButton(pcontext, &rcPart, CLOSEBUTTON, iState);
403  ThemeDrawCaptionButton(pcontext, &rcPart, MAXBUTTON, iState);
404  ThemeDrawCaptionButton(pcontext, &rcPart, MINBUTTON, iState);
405  ThemeDrawCaptionButton(pcontext, &rcPart, HELPBUTTON, iState);
406  }
407 
408  rcPart.top += 3 ;
409 
410  /* Draw the icon */
411  if (hIcon)
412  {
413  int IconHeight = GetSystemMetrics(SM_CYSMICON);
414  int IconWidth = GetSystemMetrics(SM_CXSMICON);
415  DrawIconEx(pcontext->hDC, rcPart.left, rcPart.top , hIcon, IconWidth, IconHeight, 0, NULL, DI_NORMAL);
416  rcPart.left += IconWidth + 4;
417  }
418 
419  rcPart.right -= 4;
420 
421  /* Draw the caption */
422  ThemeDrawCaptionText(pcontext, &rcPart, iPart, iState);
423 }
BOOL WINAPI InflateRect(_Inout_ LPRECT, _In_ int, _In_ int)
static HICON
Definition: imagelist.c:84
static void ThemeDrawCaptionButton(PDRAW_CONTEXT pcontext, RECT *prcCurrent, CAPTIONBUTTON buttonId, INT iStateId)
Definition: nonclient.c:274
DWORD dwStyle
Definition: winuser.h:3744
LONG top
Definition: windef.h:307
UINT cyWindowBorders
Definition: winuser.h:3748
#define SM_CYSMICON
Definition: winuser.h:1003
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
HRESULT WINAPI DrawThemeBackground(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, const RECT *pClipRect)
Definition: draw.c:128
#define WS_EX_TOOLWINDOW
Definition: winuser.h:404
static HICON UserGetWindowIcon(PDRAW_CONTEXT pcontext)
Definition: nonclient.c:58
#define WS_MINIMIZE
Definition: pedump.c:622
smooth NULL
Definition: ftsmooth.c:416
WINDOWINFO wi
Definition: uxthemep.h:180
DWORD dwExStyle
Definition: winuser.h:3745
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:1997
int WINAPI GetSystemMetrics(_In_ int)
#define SM_CXSMICON
Definition: winuser.h:1002
#define DI_NORMAL
Definition: wingdi.h:72
int CaptionHeight
Definition: uxthemep.h:183
#define BUTTON_GAP_SIZE
Definition: uxthemep.h:224
HICON hIcon
Definition: msconfig.c:44
HTHEME theme
Definition: uxthemep.h:177
LONG bottom
Definition: windef.h:309
#define WS_SYSMENU
Definition: pedump.c:629
HRESULT WINAPI ThemeDrawCaptionText(PDRAW_CONTEXT pcontext, RECT *pRect, int iPartId, int iStateId)
Definition: nonclient.c:83
#define WS_MAXIMIZE
Definition: pedump.c:623

Referenced by ThemePaintWindow().

◆ ThemeDrawCaptionButton()

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

Definition at line 274 of file nonclient.c.

278 {
279  INT iPartId;
280  HMENU SysMenu;
281  UINT MenuState;
282  PWND_DATA pwndData = ThemeGetWndData(pcontext->hWnd);
283  if (!pwndData)
284  return;
285 
286  switch(buttonId)
287  {
288  case CLOSEBUTTON:
289  SysMenu = GetSystemMenu(pcontext->hWnd, FALSE);
290  MenuState = GetMenuState(SysMenu, SC_CLOSE, MF_BYCOMMAND);
291  if (!(pcontext->wi.dwStyle & WS_SYSMENU) || (MenuState & (MF_GRAYED | MF_DISABLED)) || pcontext->wi.dwStyle & CS_NOCLOSE)
292  {
293  iStateId = (pcontext->Active ? BUTTON_DISABLED : BUTTON_INACTIVE_DISABLED);
294  }
295 
297  break;
298 
299  case MAXBUTTON:
300  if (!(pcontext->wi.dwStyle & WS_MAXIMIZEBOX))
301  {
302  if (!(pcontext->wi.dwStyle & WS_MINIMIZEBOX))
303  return;
304  else
305  iStateId = (pcontext->Active ? BUTTON_DISABLED : BUTTON_INACTIVE_DISABLED);
306  }
307 
308  iPartId = pcontext->wi.dwStyle & WS_MAXIMIZE ? WP_RESTOREBUTTON : WP_MAXBUTTON;
309  break;
310 
311  case MINBUTTON:
312  if (!(pcontext->wi.dwStyle & WS_MINIMIZEBOX))
313  {
314  if (!(pcontext->wi.dwStyle & WS_MAXIMIZEBOX))
315  return;
316  else
317  iStateId = (pcontext->Active ? BUTTON_DISABLED : BUTTON_INACTIVE_DISABLED);
318  }
319 
320  iPartId = pcontext->wi.dwStyle & WS_MINIMIZE ? WP_RESTOREBUTTON : WP_MINBUTTON;
321  break;
322 
323  default:
324  //FIXME: Implement Help Button
325  return;
326  }
327 
328  if (prcCurrent)
329  prcCurrent->right = pwndData->rcCaptionButtons[buttonId].left;
330 
331  DrawThemeBackground(pcontext->theme, pcontext->hDC, iPartId, iStateId, &pwndData->rcCaptionButtons[buttonId], NULL);
332 }
#define MF_DISABLED
Definition: winuser.h:130
#define MF_BYCOMMAND
Definition: winuser.h:202
DWORD dwStyle
Definition: winuser.h:3744
UINT WINAPI GetMenuState(_In_ HMENU, _In_ UINT, _In_ UINT)
#define CS_NOCLOSE
Definition: winuser.h:649
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
HRESULT WINAPI DrawThemeBackground(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, const RECT *pClipRect)
Definition: draw.c:128
#define WS_EX_TOOLWINDOW
Definition: winuser.h:404
int32_t INT
Definition: typedefs.h:58
#define FALSE
Definition: types.h:117
#define WS_MINIMIZE
Definition: pedump.c:622
HMENU WINAPI GetSystemMenu(_In_ HWND, _In_ BOOL)
smooth NULL
Definition: ftsmooth.c:416
#define WS_MAXIMIZEBOX
Definition: pedump.c:632
WINDOWINFO wi
Definition: uxthemep.h:180
DWORD dwExStyle
Definition: winuser.h:3745
RECT rcCaptionButtons[4]
Definition: uxthemep.h:154
#define WS_MINIMIZEBOX
Definition: pedump.c:631
HTHEME theme
Definition: uxthemep.h:177
unsigned int UINT
Definition: ndis.h:50
#define SC_CLOSE
Definition: winuser.h:2567
PWND_DATA ThemeGetWndData(HWND hWnd)
Definition: themehooks.c:17
#define MF_GRAYED
Definition: winuser.h:129
#define WS_SYSMENU
Definition: pedump.c:629
static const CLSID *static CLSID *static const GUID VARIANT VARIANT *static IServiceProvider DWORD *static HMENU
Definition: ordinal.c:60
#define WS_MAXIMIZE
Definition: pedump.c:623

Referenced by ThemeDrawCaption(), and ThemeDrawCaptionButtons().

◆ ThemeDrawCaptionButtons()

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

Definition at line 347 of file nonclient.c.

348 {
349  /* Draw the buttons */
351  ThemeGetButtonState(HTCLOSE, htHot, htDown, pcontext->Active));
353  ThemeGetButtonState(HTMAXBUTTON, htHot, htDown, pcontext->Active));
355  ThemeGetButtonState(HTMINBUTTON, htHot, htDown, pcontext->Active));
357  ThemeGetButtonState(HTHELP, htHot, htDown, pcontext->Active));
358 }
#define HTMAXBUTTON
Definition: winuser.h:2459
static void ThemeDrawCaptionButton(PDRAW_CONTEXT pcontext, RECT *prcCurrent, CAPTIONBUTTON buttonId, INT iStateId)
Definition: nonclient.c:274
#define HTMINBUTTON
Definition: winuser.h:2458
smooth NULL
Definition: ftsmooth.c:416
#define HTCLOSE
Definition: winuser.h:2474
static DWORD ThemeGetButtonState(DWORD htCurrect, DWORD htHot, DWORD htDown, BOOL Active)
Definition: nonclient.c:335
#define HTHELP
Definition: winuser.h:2475

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

◆ ThemeDrawCaptionText()

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

Definition at line 83 of file nonclient.c.

84 {
85  HRESULT hr;
86  HFONT hFont = NULL;
87  HGDIOBJ oldFont = NULL;
88  LOGFONTW logfont;
89  COLORREF textColor;
90  COLORREF oldTextColor;
91  int align = CA_LEFT;
92  int drawStyles = DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS;
93 
94  WCHAR buffer[50];
95  WCHAR *pszText = buffer;
96  INT len;
97 
98  len = InternalGetWindowText(pcontext->hWnd, NULL, 0);
99  if (!len)
100  return S_OK;
101 
102  len++; /* From now on this is the size of the buffer so include the null */
103 
104  if (len > ARRAYSIZE(buffer))
105  {
106  pszText = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
107  if (!pszText)
108  return E_OUTOFMEMORY;
109  }
110 
111  InternalGetWindowText(pcontext->hWnd, pszText, len);
112 
113  hr = GetThemeSysFont(0,TMT_CAPTIONFONT,&logfont);
114  if(SUCCEEDED(hr))
115  hFont = CreateFontIndirectW(&logfont);
116 
117  if(hFont)
118  oldFont = SelectObject(pcontext->hDC, hFont);
119 
120  if (!pcontext->Active)
122  else
123  textColor = GetSysColor(COLOR_CAPTIONTEXT);
124 
125  GetThemeEnumValue(pcontext->theme, iPartId, iStateId, TMT_CONTENTALIGNMENT, &align);
126  if (align == CA_CENTER)
127  drawStyles |= DT_CENTER;
128  else if (align == CA_RIGHT)
129  drawStyles |= DT_RIGHT;
130 
131  oldTextColor = SetTextColor(pcontext->hDC, textColor);
132  DrawThemeText(pcontext->theme,
133  pcontext->hDC,
134  iPartId,
135  iStateId,
136  pszText,
137  len - 1,
138  drawStyles,
139  0,
140  pRect);
141  SetTextColor(pcontext->hDC, oldTextColor);
142 
143  if (hFont)
144  {
145  SelectObject(pcontext->hDC, oldFont);
147  }
148  if (pszText != buffer)
149  {
150  HeapFree(GetProcessHeap(), 0, pszText);
151  }
152  return S_OK;
153 }
HRESULT hr
Definition: shlfolder.c:183
HRESULT WINAPI GetThemeEnumValue(HTHEME hTheme, int iPartId, int iStateId, int iPropId, int *piVal)
Definition: property.c:63
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1499
#define COLOR_CAPTIONTEXT
Definition: winuser.h:912
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
GLuint buffer
Definition: glext.h:5915
#define DT_RIGHT
Definition: winuser.h:538
int align(int length, int align)
Definition: dsound8.c:36
int32_t INT
Definition: typedefs.h:58
DWORD WINAPI GetSysColor(_In_ int)
HFONT hFont
Definition: main.c:53
#define TMT_CAPTIONFONT
Definition: vssym32.h:164
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
HRESULT WINAPI GetThemeSysFont(HTHEME hTheme, int iFontID, LOGFONTW *plf)
Definition: metric.c:91
#define DT_END_ELLIPSIS
Definition: winuser.h:529
smooth NULL
Definition: ftsmooth.c:416
HFONT WINAPI CreateFontIndirectW(_In_ const LOGFONTW *)
#define DT_VCENTER
Definition: winuser.h:543
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
DWORD COLORREF
Definition: windef.h:300
#define COLOR_INACTIVECAPTIONTEXT
Definition: winuser.h:924
GLenum GLsizei len
Definition: glext.h:6722
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:888
#define DT_SINGLELINE
Definition: winuser.h:540
#define S_OK
Definition: intsafe.h:51
INT WINAPI InternalGetWindowText(_In_ HWND hWnd, _Out_writes_to_(cchMaxCount, return+1) LPWSTR pString, _In_ int cchMaxCount)
HTHEME theme
Definition: uxthemep.h:177
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
#define DT_CENTER
Definition: winuser.h:527
#define HeapFree(x, y, z)
Definition: compat.h:594
#define TMT_CONTENTALIGNMENT
Definition: vssym32.h:358
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
#define SUCCEEDED(hr)
Definition: intsafe.h:49

Referenced by ThemeDrawCaption().

◆ ThemeDrawMenuBar()

static void ThemeDrawMenuBar ( PDRAW_CONTEXT  pcontext,
RECT prcCurrent 
)
static

Definition at line 515 of file nonclient.c.

516 {
517  /* Let the window manager paint the menu */
518  prcCurrent->top += PaintMenuBar(pcontext->hWnd,
519  pcontext->hDC,
520  pcontext->wi.cxWindowBorders,
521  pcontext->wi.cxWindowBorders,
522  prcCurrent->top,
523  pcontext->Active);
524 }
UINT cxWindowBorders
Definition: winuser.h:3747
LONG top
Definition: windef.h:307
WINDOWINFO wi
Definition: uxthemep.h:180
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 526 of file nonclient.c.

527 {
528  RECT rcPart;
530  RECT ParentClientRect;
531  DWORD ParentStyle;
532 
533  rcPart = *prcCurrent;
534 
535  if (pcontext->wi.dwExStyle & WS_EX_LEFTSCROLLBAR)
536  rcPart.right = rcPart.left + GetSystemMetrics(SM_CXVSCROLL);
537  else
538  rcPart.left = rcPart.right - GetSystemMetrics(SM_CXVSCROLL);
539 
540  rcPart.top = rcPart.bottom - GetSystemMetrics(SM_CYHSCROLL);
541 
542  FillRect(pcontext->hDC, &rcPart, GetSysColorBrush(COLOR_BTNFACE));
543 
544  hwndParent = GetParent(pcontext->hWnd);
545  GetClientRect(hwndParent, &ParentClientRect);
546  ParentStyle = GetWindowLongW(hwndParent, GWL_STYLE);
547 
548  if (HASSIZEGRIP(pcontext->wi.dwStyle, pcontext->wi.dwExStyle, ParentStyle, pcontext->wi.rcWindow, ParentClientRect))
549  {
550  int iState;
551  if (pcontext->wi.dwExStyle & WS_EX_LEFTSCROLLBAR)
552  iState = pcontext->wi.dwExStyle & WS_EX_LEFTSCROLLBAR;
553  else
554  iState = SZB_RIGHTALIGN;
555  DrawThemeBackground(pcontext->scrolltheme, pcontext->hDC, SBP_SIZEBOX, iState, &rcPart, NULL);
556  }
557 }
#define SM_CYHSCROLL
Definition: winuser.h:952
DWORD dwStyle
Definition: winuser.h:3744
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
#define WS_EX_LEFTSCROLLBAR
Definition: winuser.h:392
HRESULT WINAPI DrawThemeBackground(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, const RECT *pClipRect)
Definition: draw.c:128
HTHEME scrolltheme
Definition: uxthemep.h:178
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
smooth NULL
Definition: ftsmooth.c:416
static HWND hwndParent
Definition: cryptui.c:300
RECT rcWindow
Definition: winuser.h:3742
WINDOWINFO wi
Definition: uxthemep.h:180
DWORD dwExStyle
Definition: winuser.h:3745
int WINAPI GetSystemMetrics(_In_ int)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define COLOR_BTNFACE
Definition: winuser.h:918
#define GWL_STYLE
Definition: winuser.h:846
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
HWND WINAPI GetParent(_In_ HWND)
#define SM_CXVSCROLL
Definition: winuser.h:951
#define HASSIZEGRIP(Style, ExStyle, ParentStyle, WindowRect, ParentClientRect)
Definition: nonclient.c:34
LONG bottom
Definition: windef.h:309
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
HBRUSH WINAPI GetSysColorBrush(_In_ int)

Referenced by ThemePaintWindow().

◆ ThemeEndBufferedPaint()

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

Definition at line 202 of file nonclient.c.

203 {
204  HBITMAP hbmp;
205  BitBlt(pcontext->hDCScreen, 0, 0, cx, cy, pcontext->hDC, x, y, SRCCOPY);
206  hbmp = (HBITMAP) SelectObject(pcontext->hDC, pcontext->hbmpOld);
207  DeleteObject(pcontext->hDC);
209 
210  pcontext->hDC = pcontext->hDCScreen;
211 }
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1499
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
HBITMAP hbmpOld
Definition: uxthemep.h:187
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:581
HBITMAP hbmp
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
_Out_opt_ int * cx
Definition: commctrl.h:581
static HBITMAP
Definition: button.c:44
#define SRCCOPY
Definition: wingdi.h:332
static VOID NTAPI 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:49

Referenced by ThemePaintWindow().

◆ ThemeGetButtonState()

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

Definition at line 335 of file nonclient.c.

336 {
337  if (htHot == htCurrect)
339  if (htDown == htCurrect)
341 
342  return (Active ? BUTTON_NORMAL : BUTTON_INACTIVE);
343 }
_In_ ULONG _In_ BOOLEAN Active
Definition: potypes.h:560

Referenced by ThemeDrawCaptionButtons().

◆ ThemeHandleButton()

static VOID ThemeHandleButton ( HWND  hWnd,
WPARAM  wParam 
)
static

Definition at line 713 of file nonclient.c.

714 {
715  MSG Msg;
716  BOOL Pressed = TRUE;
717  WPARAM SCMsg, ht;
718  ULONG Style;
720  PWND_DATA pwndData;
721 
723  if (!((Style & WS_CAPTION) && (Style & WS_SYSMENU)))
724  return ;
725 
726  switch (wParam)
727  {
728  case HTCLOSE:
729  SCMsg = SC_CLOSE;
730  break;
731  case HTMINBUTTON:
732  if (!(Style & WS_MINIMIZEBOX))
733  return;
734  SCMsg = ((Style & WS_MINIMIZE) ? SC_RESTORE : SC_MINIMIZE);
735  break;
736  case HTMAXBUTTON:
737  if (!(Style & WS_MAXIMIZEBOX))
738  return;
739  SCMsg = ((Style & WS_MAXIMIZE) ? SC_RESTORE : SC_MAXIMIZE);
740  break;
741  default :
742  return;
743  }
744 
745  /* Get theme data for this window */
746  pwndData = ThemeGetWndData(hWnd);
747  if (pwndData == NULL)
748  return;
749 
752  pwndData->lastHitTest = wParam;
753 
754  SetCapture(hWnd);
755 
756  ht = wParam;
757 
758  for (;;)
759  {
760  if (GetMessageW(&Msg, 0, WM_MOUSEFIRST, WM_MOUSELAST) <= 0)
761  break;
762 
763  if (Msg.message == WM_LBUTTONUP)
764  break;
765 
766  if (Msg.message != WM_MOUSEMOVE)
767  continue;
768 
769  ht = SendMessage(hWnd, WM_NCHITTEST, 0, MAKELPARAM(Msg.pt.x, Msg.pt.y));
770  Pressed = (ht == wParam);
771 
772  /* Only draw the buttons if the hit test changed */
773  if (ht != pwndData->lastHitTest &&
774  (HT_ISBUTTON(ht) || HT_ISBUTTON(pwndData->lastHitTest)))
775  {
776  ThemeDrawCaptionButtons(&context, 0, Pressed ? wParam: 0);
777  pwndData->lastHitTest = ht;
778  }
779  }
780 
783 
784  ReleaseCapture();
785 
786  if (Pressed)
787  SendMessageW(hWnd, WM_SYSCOMMAND, SCMsg, 0);
788 }
#define HTMAXBUTTON
Definition: winuser.h:2459
return
Definition: dirsup.c:529
#define WM_MOUSEFIRST
Definition: winuser.h:1756
#define SC_RESTORE
Definition: winuser.h:2573
Definition: http.c:7094
#define TRUE
Definition: types.h:120
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
void ThemeCleanupDrawContext(PDRAW_CONTEXT pcontext)
Definition: nonclient.c:180
#define MAKELPARAM(l, h)
Definition: winuser.h:3983
HWND hWnd
Definition: settings.c:17
void ThemeInitDrawContext(PDRAW_CONTEXT pcontext, HWND hWnd, HRGN hRgn)
Definition: nonclient.c:156
#define HT_ISBUTTON(ht)
Definition: uxthemep.h:214
#define WM_NCHITTEST
Definition: winuser.h:1668
struct @1610 Msg[]
UINT_PTR WPARAM
Definition: windef.h:207
#define HTMINBUTTON
Definition: winuser.h:2458
WPARAM wParam
Definition: combotst.c:138
#define WS_MINIMIZE
Definition: pedump.c:622
unsigned int BOOL
Definition: ntddk_ex.h:94
#define SC_MAXIMIZE
Definition: winuser.h:2563
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
smooth NULL
Definition: ftsmooth.c:416
#define WS_MAXIMIZEBOX
Definition: pedump.c:632
#define WS_CAPTION
Definition: pedump.c:624
const DWORD Style
Definition: appswitch.c:71
#define WM_MOUSELAST
Definition: winuser.h:1783
UINT lastHitTest
Definition: uxthemep.h:155
#define HTCLOSE
Definition: winuser.h:2474
static void ThemeDrawCaptionButtons(PDRAW_CONTEXT pcontext, DWORD htHot, DWORD htDown)
Definition: nonclient.c:347
#define SC_MINIMIZE
Definition: winuser.h:2561
#define GWL_STYLE
Definition: winuser.h:846
HWND WINAPI SetCapture(_In_ HWND hWnd)
#define WS_MINIMIZEBOX
Definition: pedump.c:631
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_LBUTTONUP
Definition: winuser.h:1759
static const struct newhuff ht[]
Definition: huffman.h:296
#define WM_MOUSEMOVE
Definition: winuser.h:1757
BOOL WINAPI GetMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT)
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2889
#define SC_CLOSE
Definition: winuser.h:2567
#define SendMessage
Definition: winuser.h:5818
unsigned int ULONG
Definition: retypes.h:1
PWND_DATA ThemeGetWndData(HWND hWnd)
Definition: themehooks.c:17
#define WS_SYSMENU
Definition: pedump.c:629
#define WM_SYSCOMMAND
Definition: winuser.h:1723
#define WS_MAXIMIZE
Definition: pedump.c:623

Referenced by ThemeWndProc().

◆ ThemeHandleNcMouseLeave()

static LRESULT ThemeHandleNcMouseLeave ( HWND  hWnd)
static

Definition at line 679 of file nonclient.c.

680 {
682  DWORD style;
683  PWND_DATA pwndData;
684 
685  /* First of all check if we have something to do here */
688  return 0;
689 
690  /* Get theme data for this window */
691  pwndData = ThemeGetWndData(hWnd);
692  if (pwndData == NULL)
693  return 0;
694 
696  if (context.wi.dwStyle & WS_SYSMENU && HT_ISBUTTON(pwndData->lastHitTest))
698 
699  if (context.wi.dwStyle & WS_HSCROLL && pwndData->lastHitTest == HTHSCROLL)
701 
702  if (context.wi.dwStyle & WS_VSCROLL && pwndData->lastHitTest == HTVSCROLL)
704 
706 
707  pwndData->lastHitTest = HTNOWHERE;
708 
709  return 0;
710 }
#define HTHSCROLL
Definition: winuser.h:2456
Definition: http.c:7094
#define SB_VERT
Definition: winuser.h:553
#define SB_HORZ
Definition: winuser.h:552
void ThemeCleanupDrawContext(PDRAW_CONTEXT pcontext)
Definition: nonclient.c:180
HWND hWnd
Definition: settings.c:17
void ThemeInitDrawContext(PDRAW_CONTEXT pcontext, HWND hWnd, HRGN hRgn)
Definition: nonclient.c:156
#define HT_ISBUTTON(ht)
Definition: uxthemep.h:214
#define HTNOWHERE
Definition: winuser.h:2449
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
smooth NULL
Definition: ftsmooth.c:416
void ThemeDrawScrollBar(PDRAW_CONTEXT pcontext, INT nBar, POINT *pt)
Definition: ncscrollbar.c:276
#define WS_CAPTION
Definition: pedump.c:624
unsigned long DWORD
Definition: ntddk_ex.h:95
UINT lastHitTest
Definition: uxthemep.h:155
#define WS_HSCROLL
Definition: pedump.c:628
static void ThemeDrawCaptionButtons(PDRAW_CONTEXT pcontext, DWORD htHot, DWORD htDown)
Definition: nonclient.c:347
#define GWL_STYLE
Definition: winuser.h:846
#define WS_VSCROLL
Definition: pedump.c:627
#define HTVSCROLL
Definition: winuser.h:2457
PWND_DATA ThemeGetWndData(HWND hWnd)
Definition: themehooks.c:17
Arabic default style
Definition: afstyles.h:93
#define WS_SYSMENU
Definition: pedump.c:629

Referenced by ThemeWndProc().

◆ ThemeHandleNcMouseMove()

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

Definition at line 624 of file nonclient.c.

625 {
627  TRACKMOUSEEVENT tme;
628  DWORD style;
629  PWND_DATA pwndData;
630 
631  /* First of all check if we have something to do here */
634  return 0;
635 
636  /* Get theme data for this window */
637  pwndData = ThemeGetWndData(hWnd);
638  if (pwndData == NULL)
639  return 0;
640 
641  /* Begin tracking in the non client area if we are not tracking yet */
642  tme.cbSize = sizeof(TRACKMOUSEEVENT);
643  tme.dwFlags = TME_QUERY;
644  tme.hwndTrack = hWnd;
645  TrackMouseEvent(&tme);
646  if (tme.dwFlags != (TME_LEAVE | TME_NONCLIENT))
647  {
648  tme.hwndTrack = hWnd;
650  TrackMouseEvent(&tme);
651  }
652 
654  if (context.wi.dwStyle & WS_SYSMENU)
655  {
656  if (HT_ISBUTTON(ht) || HT_ISBUTTON(pwndData->lastHitTest))
658  }
659 
660  if (context.wi.dwStyle & WS_HSCROLL)
661  {
662  if (ht == HTHSCROLL || pwndData->lastHitTest == HTHSCROLL)
664  }
665 
666  if (context.wi.dwStyle & WS_VSCROLL)
667  {
668  if (ht == HTVSCROLL || pwndData->lastHitTest == HTVSCROLL)
670  }
672 
673  pwndData->lastHitTest = ht;
674 
675  return 0;
676 }
#define HTHSCROLL
Definition: winuser.h:2456
#define TME_NONCLIENT
Definition: commctrl.h:4978
Definition: http.c:7094
#define SB_VERT
Definition: winuser.h:553
#define pt(x, y)
Definition: drawing.c:79
#define SB_HORZ
Definition: winuser.h:552
void ThemeCleanupDrawContext(PDRAW_CONTEXT pcontext)
Definition: nonclient.c:180
HWND hWnd
Definition: settings.c:17
void ThemeInitDrawContext(PDRAW_CONTEXT pcontext, HWND hWnd, HRGN hRgn)
Definition: nonclient.c:156
#define HT_ISBUTTON(ht)
Definition: uxthemep.h:214
BOOL WINAPI TrackMouseEvent(_Inout_ LPTRACKMOUSEEVENT)
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
smooth NULL
Definition: ftsmooth.c:416
void ThemeDrawScrollBar(PDRAW_CONTEXT pcontext, INT nBar, POINT *pt)
Definition: ncscrollbar.c:276
#define WS_CAPTION
Definition: pedump.c:624
#define TME_QUERY
Definition: commctrl.h:4979
unsigned long DWORD
Definition: ntddk_ex.h:95
UINT lastHitTest
Definition: uxthemep.h:155
#define WS_HSCROLL
Definition: pedump.c:628
struct tagTRACKMOUSEEVENT TRACKMOUSEEVENT
static void ThemeDrawCaptionButtons(PDRAW_CONTEXT pcontext, DWORD htHot, DWORD htDown)
Definition: nonclient.c:347
#define GWL_STYLE
Definition: winuser.h:846
#define TME_LEAVE
Definition: commctrl.h:4977
static const struct newhuff ht[]
Definition: huffman.h:296
#define WS_VSCROLL
Definition: pedump.c:627
#define HTVSCROLL
Definition: winuser.h:2457
PWND_DATA ThemeGetWndData(HWND hWnd)
Definition: themehooks.c:17
Arabic default style
Definition: afstyles.h:93
#define WS_SYSMENU
Definition: pedump.c:629

Referenced by ThemeWndProc().

◆ ThemeHandleNCPaint()

static LRESULT ThemeHandleNCPaint ( HWND  hWnd,
HRGN  hRgn 
)
static

Definition at line 607 of file nonclient.c.

608 {
610  RECT rcCurrent;
611 
613 
614  rcCurrent = context.wi.rcWindow;
615  OffsetRect( &rcCurrent, -context.wi.rcWindow.left, -context.wi.rcWindow.top);
616 
617  ThemePaintWindow(&context, &rcCurrent, TRUE);
619 
620  return 0;
621 }
BOOL WINAPI OffsetRect(_Inout_ LPRECT, _In_ int, _In_ int)
Definition: http.c:7094
#define TRUE
Definition: types.h:120
void ThemeCleanupDrawContext(PDRAW_CONTEXT pcontext)
Definition: nonclient.c:180
HWND hWnd
Definition: settings.c:17
void ThemeInitDrawContext(PDRAW_CONTEXT pcontext, HWND hWnd, HRGN hRgn)
Definition: nonclient.c:156
static HRGN hRgn
Definition: mapping.c:33
static void ThemePaintWindow(PDRAW_CONTEXT pcontext, RECT *prcCurrent, BOOL bDoDoubleBuffering)
Definition: nonclient.c:560

Referenced by ThemeWndProc().

◆ ThemeInitDrawContext()

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

Definition at line 156 of file nonclient.c.

159 {
160  pcontext->wi.cbSize = sizeof(pcontext->wi);
161  GetWindowInfo(hWnd, &pcontext->wi);
162  pcontext->hWnd = hWnd;
163  pcontext->Active = IsWindowActive(hWnd, pcontext->wi.dwExStyle);
164  pcontext->theme = GetNCCaptionTheme(hWnd, pcontext->wi.dwStyle);
165  pcontext->scrolltheme = GetNCScrollbarTheme(hWnd, pcontext->wi.dwStyle);
166 
167  pcontext->CaptionHeight = pcontext->wi.cyWindowBorders;
169 
170  if(hRgn <= (HRGN)1)
171  {
172  hRgn = CreateRectRgnIndirect(&pcontext->wi.rcWindow);
173  }
174  pcontext->hRgn = hRgn;
175 
177 }
HTHEME GetNCCaptionTheme(HWND hWnd, DWORD style)
Definition: themehooks.c:88
HDC WINAPI GetDCEx(_In_opt_ HWND, _In_opt_ HRGN, _In_ DWORD)
DWORD cbSize
Definition: winuser.h:3741
DWORD dwStyle
Definition: winuser.h:3744
HRGN WINAPI CreateRectRgnIndirect(_In_ LPCRECT)
HWND hWnd
Definition: settings.c:17
static HRGN hRgn
Definition: mapping.c:33
#define DCX_USESTYLE
Definition: GetDCEx.c:10
UINT cyWindowBorders
Definition: winuser.h:3748
#define WS_EX_TOOLWINDOW
Definition: winuser.h:404
#define DCX_INTERSECTRGN
Definition: winuser.h:2104
#define DCX_WINDOW
Definition: winuser.h:2095
HTHEME scrolltheme
Definition: uxthemep.h:178
#define DCX_KEEPCLIPRGN
Definition: undocuser.h:66
RECT rcWindow
Definition: winuser.h:3742
WINDOWINFO wi
Definition: uxthemep.h:180
DWORD dwExStyle
Definition: winuser.h:3745
#define SM_CYCAPTION
Definition: winuser.h:953
int WINAPI GetSystemMetrics(_In_ int)
HTHEME GetNCScrollbarTheme(HWND hWnd, DWORD style)
Definition: themehooks.c:118
int CaptionHeight
Definition: uxthemep.h:183
BOOL WINAPI GetWindowInfo(_In_ HWND, _Inout_ PWINDOWINFO)
static BOOL IsWindowActive(HWND hWnd, DWORD ExStyle)
Definition: nonclient.c:12
HTHEME theme
Definition: uxthemep.h:177
#define SM_CYSMCAPTION
Definition: winuser.h:1004

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

◆ ThemePaintWindow()

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

Definition at line 560 of file nonclient.c.

561 {
562  if(!(pcontext->wi.dwStyle & WS_VISIBLE))
563  return;
564 
565  if((pcontext->wi.dwStyle & WS_CAPTION)==WS_CAPTION)
566  {
567  if (bDoDoubleBuffering)
568  ThemeStartBufferedPaint(pcontext, prcCurrent->right, pcontext->CaptionHeight);
569  ThemeDrawCaption(pcontext, prcCurrent);
570  if (bDoDoubleBuffering)
571  ThemeEndBufferedPaint(pcontext, 0, 0, prcCurrent->right, pcontext->CaptionHeight);
572  ThemeDrawBorders(pcontext, prcCurrent);
573  }
574  else
575  {
576  DrawClassicFrame(pcontext, prcCurrent);
577  }
578 
579  if(pcontext->wi.dwStyle & WS_MINIMIZE)
580  return;
581 
582  if(HAS_MENU(pcontext->hWnd, pcontext->wi.dwStyle))
583  ThemeDrawMenuBar(pcontext, prcCurrent);
584 
585  if (pcontext->wi.dwExStyle & WS_EX_CLIENTEDGE)
586  DrawEdge(pcontext->hDC, prcCurrent, EDGE_SUNKEN, BF_RECT | BF_ADJUST);
587 
588  if((pcontext->wi.dwStyle & WS_HSCROLL) && IsScrollBarVisible(pcontext->hWnd, OBJID_HSCROLL))
589  ThemeDrawScrollBar(pcontext, SB_HORZ , NULL);
590 
591  if((pcontext->wi.dwStyle & WS_VSCROLL) && IsScrollBarVisible(pcontext->hWnd, OBJID_VSCROLL))
592  ThemeDrawScrollBar(pcontext, SB_VERT, NULL);
593 
594  if((pcontext->wi.dwStyle & (WS_HSCROLL|WS_VSCROLL)) == (WS_HSCROLL|WS_VSCROLL) &&
595  IsScrollBarVisible(pcontext->hWnd, OBJID_HSCROLL) &&
597  {
598  ThemeDrawScrollBarsGrip(pcontext, prcCurrent);
599  }
600 }
static void DrawClassicFrame(PDRAW_CONTEXT context, RECT *prcCurrent)
Definition: nonclient.c:451
#define SB_VERT
Definition: winuser.h:553
static void ThemeEndBufferedPaint(PDRAW_CONTEXT pcontext, int x, int y, int cx, int cy)
Definition: nonclient.c:202
DWORD dwStyle
Definition: winuser.h:3744
#define SB_HORZ
Definition: winuser.h:552
static void ThemeDrawBorders(PDRAW_CONTEXT pcontext, RECT *prcCurrent)
Definition: nonclient.c:426
LONG right
Definition: windef.h:308
#define BF_ADJUST
Definition: winuser.h:470
#define BF_RECT
Definition: winuser.h:462
static void ThemeDrawScrollBarsGrip(PDRAW_CONTEXT pcontext, RECT *prcCurrent)
Definition: nonclient.c:526
#define WS_MINIMIZE
Definition: pedump.c:622
BOOL WINAPI DrawEdge(_In_ HDC, _Inout_ LPRECT, _In_ UINT, _In_ UINT)
smooth NULL
Definition: ftsmooth.c:416
void ThemeDrawScrollBar(PDRAW_CONTEXT pcontext, INT nBar, POINT *pt)
Definition: ncscrollbar.c:276
WINDOWINFO wi
Definition: uxthemep.h:180
#define WS_CAPTION
Definition: pedump.c:624
DWORD dwExStyle
Definition: winuser.h:3745
#define OBJID_HSCROLL
Definition: winable.h:21
static void ThemeStartBufferedPaint(PDRAW_CONTEXT pcontext, int cx, int cy)
Definition: nonclient.c:191
#define OBJID_VSCROLL
Definition: winable.h:20
#define WS_HSCROLL
Definition: pedump.c:628
int CaptionHeight
Definition: uxthemep.h:183
BOOL IsScrollBarVisible(HWND hWnd, INT hBar)
Definition: nonclient.c:31
#define HAS_MENU(hwnd, style)
Definition: uxthemep.h:222
#define WS_EX_CLIENTEDGE
Definition: winuser.h:384
#define WS_VSCROLL
Definition: pedump.c:627
static void ThemeDrawMenuBar(PDRAW_CONTEXT pcontext, RECT *prcCurrent)
Definition: nonclient.c:515
static void ThemeDrawCaption(PDRAW_CONTEXT pcontext, RECT *prcCurrent)
Definition: nonclient.c:362
#define EDGE_SUNKEN
Definition: winuser.h:451
#define WS_VISIBLE
Definition: pedump.c:620

Referenced by DrawNCPreview(), and ThemeHandleNCPaint().

◆ ThemeStartBufferedPaint()

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

Definition at line 191 of file nonclient.c.

192 {
193  HBITMAP hbmp;
194 
195  pcontext->hDCScreen = pcontext->hDC;
196  pcontext->hDC = CreateCompatibleDC(pcontext->hDCScreen);
197  hbmp = CreateCompatibleBitmap(pcontext->hDCScreen, cx, cy);
198  pcontext->hbmpOld = (HBITMAP)SelectObject(pcontext->hDC, hbmp);
199 }
HBITMAP WINAPI CreateCompatibleBitmap(_In_ HDC hdc, _In_ INT cx, _In_ INT cy)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1499
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
HBITMAP hbmpOld
Definition: uxthemep.h:187
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:581
HBITMAP hbmp
_Out_opt_ int * cx
Definition: commctrl.h:581
static HBITMAP
Definition: button.c:44

Referenced by ThemePaintWindow().

◆ ThemeWndProc()

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

Definition at line 1007 of file nonclient.c.

1008 {
1009  switch(Msg)
1010  {
1011  case WM_NCPAINT:
1012  return ThemeHandleNCPaint(hWnd, (HRGN)wParam);
1013  //
1014  // WM_NCUAHDRAWCAPTION : wParam are DC_* flags.
1015  //
1016  case WM_NCUAHDRAWCAPTION:
1017  //
1018  // WM_NCUAHDRAWFRAME : wParam is HDC, lParam are DC_ACTIVE and or DC_REDRAWHUNGWND.
1019  //
1020  case WM_NCUAHDRAWFRAME:
1021  case WM_NCACTIVATE:
1022 
1024  return TRUE;
1025 
1026  ThemeHandleNCPaint(hWnd, (HRGN)1);
1027  return TRUE;
1028  case WM_NCMOUSEMOVE:
1029  {
1030  POINT Point;
1034  }
1035  case WM_NCMOUSELEAVE:
1036  return ThemeHandleNcMouseLeave(hWnd);
1037  case WM_NCLBUTTONDOWN:
1038  switch (wParam)
1039  {
1040  case HTMINBUTTON:
1041  case HTMAXBUTTON:
1042  case HTCLOSE:
1043  {
1045  return 0;
1046  }
1047  default:
1048  return DefWndProc(hWnd, Msg, wParam, lParam);
1049  }
1050  case WM_NCHITTEST:
1051  {
1052  POINT Point;
1055  return DefWndNCHitTest(hWnd, Point);
1056  }
1057  case WM_SYSCOMMAND:
1058  {
1059  if((wParam & 0xfff0) == SC_VSCROLL ||
1060  (wParam & 0xfff0) == SC_HSCROLL)
1061  {
1062  POINT Pt;
1063  Pt.x = (short)LOWORD(lParam);
1064  Pt.y = (short)HIWORD(lParam);
1066  return 0;
1067  }
1068  else
1069  {
1070  return DefWndProc(hWnd, Msg, wParam, lParam);
1071  }
1072  }
1073  default:
1074  return DefWndProc(hWnd, Msg, wParam, lParam);
1075  }
1076 }
#define WM_NCLBUTTONDOWN
Definition: winuser.h:1674
#define HTMAXBUTTON
Definition: winuser.h:2459
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
#define TRUE
Definition: types.h:120
HWND hWnd
Definition: settings.c:17
#define GET_X_LPARAM(lp)
Definition: windowsx.h:274
static LRESULT ThemeHandleNcMouseMove(HWND hWnd, DWORD ht, POINT *pt)
Definition: nonclient.c:624
#define WM_NCHITTEST
Definition: winuser.h:1668
struct @1610 Msg[]
#define HTMINBUTTON
Definition: winuser.h:2458
WPARAM wParam
Definition: combotst.c:138
#define WM_NCPAINT
Definition: winuser.h:1669
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:94
static LRESULT DefWndNCHitTest(HWND hWnd, POINT Point)
Definition: nonclient.c:792
#define WM_NCACTIVATE
Definition: winuser.h:1670
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
static LRESULT ThemeHandleNCPaint(HWND hWnd, HRGN hRgn)
Definition: nonclient.c:607
#define WS_CAPTION
Definition: pedump.c:624
#define WM_NCUAHDRAWCAPTION
Definition: undocuser.h:45
void NC_TrackScrollBar(HWND hwnd, WPARAM wParam, POINT pt)
Definition: ncscrollbar.c:665
#define HTCLOSE
Definition: winuser.h:2474
struct Point Point
#define GWL_STYLE
Definition: winuser.h:846
static LRESULT ThemeHandleNcMouseLeave(HWND hWnd)
Definition: nonclient.c:679
#define GET_Y_LPARAM(lp)
Definition: windowsx.h:275
#define WM_NCUAHDRAWFRAME
Definition: undocuser.h:46
#define HIWORD(l)
Definition: typedefs.h:247
#define WM_NCMOUSELEAVE
Definition: winuser.h:1824
static VOID ThemeHandleButton(HWND hWnd, WPARAM wParam)
Definition: nonclient.c:713
#define WM_SYSCOMMAND
Definition: winuser.h:1723
#define SC_VSCROLL
Definition: winuser.h:2568
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define WM_NCMOUSEMOVE
Definition: winuser.h:1673
#define SC_HSCROLL
Definition: winuser.h:2569

Referenced by ThemeDefWindowProcA(), and ThemeDefWindowProcW().

◆ UserGetWindowIcon()

static HICON UserGetWindowIcon ( PDRAW_CONTEXT  pcontext)
static

Definition at line 58 of file nonclient.c.

59 {
60  HICON hIcon = NULL;
61 
62  SendMessageTimeout(pcontext->hWnd, WM_GETICON, ICON_SMALL2, 0, SMTO_ABORTIFHUNG, 1000, (PDWORD_PTR)&hIcon);
63 
64  if (!hIcon)
65  SendMessageTimeout(pcontext->hWnd, WM_GETICON, ICON_SMALL, 0, SMTO_ABORTIFHUNG, 1000, (PDWORD_PTR)&hIcon);
66 
67  if (!hIcon)
68  SendMessageTimeout(pcontext->hWnd, WM_GETICON, ICON_BIG, 0, SMTO_ABORTIFHUNG, 1000, (PDWORD_PTR)&hIcon);
69 
70  if (!hIcon)
72 
73  if (!hIcon)
74  hIcon = (HICON)GetClassLongPtr(pcontext->hWnd, GCLP_HICON);
75 
76  // See also win32ss/user/ntuser/nonclient.c!NC_IconForWindow
77  if (!hIcon && !(pcontext->wi.dwExStyle & WS_EX_DLGMODALFRAME))
79 
80  return hIcon;
81 }
static HICON
Definition: imagelist.c:84
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define SMTO_ABORTIFHUNG
Definition: winuser.h:1209
#define ICON_SMALL
Definition: tnclass.cpp:48
smooth NULL
Definition: ftsmooth.c:416
#define WS_EX_DLGMODALFRAME
Definition: pedump.c:645
WINDOWINFO wi
Definition: uxthemep.h:180
#define GCLP_HICONSM
Definition: winuser.h:670
DWORD dwExStyle
Definition: winuser.h:3745
#define SendMessageTimeout
Definition: winuser.h:5820
#define IDI_WINLOGO
Definition: winuser.h:704
ULONG_PTR * PDWORD_PTR
Definition: basetsd.h:184
#define GCLP_HICON
Definition: winuser.h:669
#define GetClassLongPtr
Definition: winuser.h:5757
HICON hIcon
Definition: msconfig.c:44
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2044
#define ICON_BIG
Definition: tnclass.cpp:51

Referenced by ThemeDrawCaption().

◆ UserHasWindowEdge()

static BOOL UserHasWindowEdge ( DWORD  Style,
DWORD  ExStyle 
)
static

Definition at line 41 of file nonclient.c.

42 {
43  if (Style & WS_MINIMIZE)
44  return TRUE;
46  return TRUE;
48  return FALSE;
49  if (Style & WS_THICKFRAME)
50  return TRUE;
51  Style &= WS_CAPTION;
52  if (Style == WS_DLGFRAME || Style == WS_CAPTION)
53  return TRUE;
54  return FALSE;
55 }
#define WS_THICKFRAME
Definition: pedump.c:630
#define TRUE
Definition: types.h:120
#define WS_DLGFRAME
Definition: pedump.c:626
#define FALSE
Definition: types.h:117
#define WS_MINIMIZE
Definition: pedump.c:622
#define WS_EX_DLGMODALFRAME
Definition: pedump.c:645
#define WS_CAPTION
Definition: pedump.c:624
const DWORD Style
Definition: appswitch.c:71
#define WS_EX_STATICEDGE
Definition: winuser.h:403
const DWORD ExStyle
Definition: appswitch.c:72

Referenced by DefWndNCHitTest(), and DrawClassicFrame().