Skip to content

Commit 32ac8f5

Browse files
ozone10kjk
authored andcommitted
Use themed sizegrip
1 parent 138107a commit 32ac8f5

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/wingui/DialogSizer.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,17 @@
55
#include "utils/WinUtil.h"
66
#include "DialogSizer.h"
77

8+
#include <Uxtheme.h>
9+
#include <vssym32.h>
10+
811
#define DIALOG_DATA_PROPERTY L"GipsySoftDialogSizerData"
912

1013
static LRESULT CALLBACK SizingProc(HWND, UINT, WPARAM, LPARAM);
1114

1215
class DialogData {
1316
public:
1417
DialogData(HWND hwnd, const DialogSizerSizingItem* psd, bool bShowSizingGrip)
15-
: hwnd(hwnd), bMaximised(false), bShowSizingGrip(bShowSizingGrip) {
18+
: hwnd(hwnd), hTheme(nullptr), bMaximised(false), bShowSizingGrip(bShowSizingGrip) {
1619
// Given an array of dialog item structures determine how many of them there
1720
// are by scanning along them until we reach the last.
1821
nItemCount = 0;
@@ -32,6 +35,10 @@ class DialogData {
3235
ptSmallest.x = rectWnd.dx;
3336
ptSmallest.y = rectWnd.dy;
3437

38+
if (hTheme == nullptr) {
39+
hTheme = OpenThemeData(hwnd, WC_SCROLLBAR);
40+
}
41+
3542
Rect rectClient = ClientRect(hwnd);
3643
sizeClient = rectClient.Size();
3744
UpdateGripperRect();
@@ -42,6 +49,9 @@ class DialogData {
4249
wndProc = (WNDPROC)SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)SizingProc);
4350
}
4451
~DialogData() {
52+
if (hTheme != nullptr) {
53+
CloseThemeData(hTheme);
54+
}
4555
SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)wndProc);
4656
RemoveProp(hwnd, DIALOG_DATA_PROPERTY);
4757
free(this->psd);
@@ -75,7 +85,11 @@ class DialogData {
7585
void DrawGripper(HDC hdc) {
7686
if (bShowSizingGrip && !bMaximised) {
7787
RECT tmpRect = ToRECT(rcGrip);
78-
DrawFrameControl(hdc, &tmpRect, DFC_SCROLL, DFCS_SCROLLSIZEGRIP);
88+
if (hTheme != nullptr) {
89+
DrawThemeBackground(hTheme, hdc, SBP_SIZEBOX, 0, &tmpRect, nullptr);
90+
} else {
91+
DrawFrameControl(hdc, &tmpRect, DFC_SCROLL, DFCS_SCROLLSIZEGRIP);
92+
}
7993
}
8094
}
8195

@@ -89,6 +103,7 @@ class DialogData {
89103
private:
90104
HWND hwnd;
91105
Rect rcGrip;
106+
HTHEME hTheme;
92107
// Draw the sizing grip...or not
93108
bool bShowSizingGrip;
94109

0 commit comments

Comments
 (0)