|
1
|
1 #include "stdafx.h"
|
|
|
2 #include <vsstyle.h>
|
|
|
3 #include "Controls.h"
|
|
|
4 #include "PaintUtils.h"
|
|
|
5 #include "HyperLinkCtrl.h"
|
|
|
6
|
|
|
7 void CStaticSeparator::OnPaint(CDCHandle) {
|
|
|
8 PaintUtils::PaintSeparatorControl(*this);
|
|
|
9 }
|
|
|
10
|
|
|
11 void CSeparator::OnPaint(CDCHandle dc) {
|
|
|
12 PaintUtils::PaintSeparatorControl(*this);
|
|
|
13 }
|
|
|
14
|
|
|
15 #if 0 // BROKEN WITH DARK MODE, DO NOT USE
|
|
|
16 CStaticMainInstruction::CStaticMainInstruction() {
|
|
|
17 SetThemePart(TEXT_MAININSTRUCTION);
|
|
|
18 }
|
|
|
19
|
|
|
20 void CStaticThemed::OnPaint(CDCHandle) {
|
|
|
21 if (m_fallback) {
|
|
|
22 SetMsgHandled(FALSE); return;
|
|
|
23 }
|
|
|
24 if (m_theme == NULL) {
|
|
|
25 m_theme.OpenThemeData(*this, L"TextStyle");
|
|
|
26 if (m_theme == NULL) {
|
|
|
27 m_fallback = true; SetMsgHandled(FALSE); return;
|
|
|
28 }
|
|
|
29 }
|
|
|
30 CPaintDC dc(*this);
|
|
|
31 TCHAR buffer[512] = {};
|
|
|
32 GetWindowText(buffer, _countof(buffer));
|
|
|
33 const int txLen = (int) pfc::strlen_max_t(buffer, _countof(buffer));
|
|
|
34 CRect contentRect;
|
|
|
35 WIN32_OP_D(GetClientRect(contentRect));
|
|
|
36 SelectObjectScope scopeFont(dc, GetFont());
|
|
|
37 dc.SetTextColor(GetSysColor(COLOR_WINDOWTEXT));
|
|
|
38 dc.SetBkMode(TRANSPARENT);
|
|
|
39
|
|
|
40 if (txLen > 0) {
|
|
|
41 CRect rcText(contentRect);
|
|
|
42 DWORD flags = 0;
|
|
|
43 DWORD style = GetStyle();
|
|
|
44 if (style & SS_LEFT) flags |= DT_LEFT;
|
|
|
45 else if (style & SS_RIGHT) flags |= DT_RIGHT;
|
|
|
46 else if (style & SS_CENTER) flags |= DT_CENTER;
|
|
|
47 if (style & SS_ENDELLIPSIS) flags |= DT_END_ELLIPSIS;
|
|
|
48
|
|
|
49 HRESULT retval = DrawThemeText(m_theme, dc, m_id, 0, buffer, txLen, flags, 0, rcText);
|
|
|
50 PFC_ASSERT(SUCCEEDED(retval));
|
|
|
51 }
|
|
|
52 }
|
|
|
53 #endif
|
|
|
54
|
|
|
55
|
|
|
56 #include "DarkMode-CHyperLink.h"
|
|
|
57 #include "windowLifetime.h"
|
|
|
58
|
|
|
59 void PP::createHyperLink(HWND wndReplaceMe) {
|
|
|
60 auto obj = PP::subclassThisWindow<DarkMode::CHyperLink>(wndReplaceMe);
|
|
|
61 obj->SetHyperLinkExtendedStyle(HLINK_NOTIFYBUTTON);
|
|
|
62 }
|
|
|
63
|
|
|
64 namespace {
|
|
|
65 class CHyperLinkLambda : public DarkMode::CHyperLinkImpl<CHyperLinkLambda> {
|
|
|
66 public:
|
|
|
67 std::function<void ()> f;
|
|
|
68 bool Navigate() {
|
|
|
69 f();
|
|
|
70 return true;
|
|
|
71 }
|
|
|
72 };
|
|
|
73 }
|
|
|
74 void PP::createHyperLink(HWND wndReplaceMe, std::function<void ()> handler) {
|
|
|
75 auto obj = PP::subclassThisWindow<CHyperLinkLambda>(wndReplaceMe);
|
|
|
76 obj->f = handler;
|
|
|
77 }
|
|
|
78
|
|
|
79 void PP::createHyperLink(HWND wndReplaceMe, const wchar_t* openURL) {
|
|
|
80 auto obj = PP::subclassThisWindow<DarkMode::CHyperLink>(wndReplaceMe);
|
|
|
81 obj->SetHyperLink(openURL);
|
|
|
82 }
|