@@ -12,13 +12,10 @@ class CWebDiffWindow : public IWebDiffWindow
12
12
public:
13
13
CWebDiffWindow ()
14
14
{
15
- s_hbrBackground = CreateSolidBrush (m_bDarkBackgroundEnabled ? RGB (0 , 0 , 0 ) : GetSysColor (COLOR_3DFACE));
16
15
}
17
16
18
17
~CWebDiffWindow ()
19
18
{
20
- if (s_hbrBackground)
21
- DeleteObject (s_hbrBackground);
22
19
}
23
20
24
21
bool Create (HINSTANCE hInstance, HWND hWndParent, int nID, const RECT& rc)
@@ -92,7 +89,7 @@ class CWebDiffWindow : public IWebDiffWindow
92
89
std::wstring userDataFolder = GetUserDataFolderPath (i);
93
90
ComPtr<IWebDiffCallback> callback2 (callback);
94
91
hr = m_webWindow[i].Create (this , m_hInstance, m_hWnd, urls[i], userDataFolder.c_str (),
95
- m_size, m_fitToWindow, m_zoom, m_bDarkBackgroundEnabled , m_userAgent, nullptr ,
92
+ m_size, m_fitToWindow, m_zoom, s_bDarkBackgroundEnabled , m_userAgent, nullptr ,
96
93
[this , i, callback2](WebDiffEvent::EVENT_TYPE event, IUnknown* sender, IUnknown* args)
97
94
{
98
95
WebDiffEvent ev{};
@@ -442,20 +439,22 @@ class CWebDiffWindow : public IWebDiffWindow
442
439
443
440
bool IsDarkBackgroundEnabled () const
444
441
{
445
- return m_bDarkBackgroundEnabled ;
442
+ return s_bDarkBackgroundEnabled ;
446
443
}
447
444
448
445
void SetDarkBackgroundEnabled (bool enabled)
449
446
{
450
- m_bDarkBackgroundEnabled = enabled;
447
+ if (s_bDarkBackgroundEnabled == enabled)
448
+ return ;
449
+ s_bDarkBackgroundEnabled = enabled;
450
+ DeleteObject (s_hbrBackground);
451
+ s_hbrBackground = CreateSolidBrush (s_bDarkBackgroundEnabled ? RGB (0 , 0 , 0 ) : GetSysColor (COLOR_3DFACE));
451
452
if (m_hWnd)
452
453
{
453
- for (int pane = 0 ; pane < m_nPanes; ++pane)
454
- m_webWindow[pane].SetDarkBackgroundEnabled (m_bDarkBackgroundEnabled);
455
- DeleteObject (s_hbrBackground);
456
- s_hbrBackground = CreateSolidBrush (m_bDarkBackgroundEnabled ? RGB (0 , 0 , 0 ) : GetSysColor (COLOR_3DFACE));
457
454
SetClassLongPtr (m_hWnd, GCLP_HBRBACKGROUND, (LONG_PTR)s_hbrBackground);
458
455
InvalidateRect (m_hWnd, NULL , TRUE );
456
+ for (int pane = 0 ; pane < m_nPanes; ++pane)
457
+ m_webWindow[pane].SetDarkBackgroundEnabled (s_bDarkBackgroundEnabled);
459
458
}
460
459
}
461
460
@@ -1544,7 +1543,7 @@ class CWebDiffWindow : public IWebDiffWindow
1544
1543
int m_nPanes = 0 ;
1545
1544
HWND m_hWnd = nullptr ;
1546
1545
HINSTANCE m_hInstance = nullptr ;
1547
- HBRUSH s_hbrBackground = nullptr ;
1546
+ inline static HBRUSH s_hbrBackground = CreateSolidBrush(GetSysColor(COLOR_3DFACE)) ;
1548
1547
CWebWindow m_webWindow[3 ];
1549
1548
int m_nDraggingSplitter = -1 ;
1550
1549
bool m_bHorizontalSplit = false ;
@@ -1562,7 +1561,7 @@ class CWebDiffWindow : public IWebDiffWindow
1562
1561
std::vector<DiffInfo> m_diffInfos;
1563
1562
DiffLocation m_diffLocation[3 ];
1564
1563
DiffOptions m_diffOptions{};
1565
- bool m_bDarkBackgroundEnabled ;
1564
+ inline static bool s_bDarkBackgroundEnabled = false ;
1566
1565
bool m_bShowDifferences = true ;
1567
1566
bool m_bShowWordDifferences = true ;
1568
1567
bool m_bSynchronizeEvents = true ;
0 commit comments