Skip to content

Instantly share code, notes, and snippets.

@ajtruckle
ajtruckle / TestDarkModeDlg.cpp
Last active January 31, 2025 15:28
Support MFC Edit Control in Dark Mode
BOOL CTestDarkModeDlg::OnInitDialog()
{
__super::OnInitDialog();
// Snipped other code for berevity
// Set the dark mode theme
SetWindowTheme(GetDlgItem(IDC_EDIT1)->GetSafeHwnd(), L"DarkMode_Explorer", nullptr);
// Tweak to render the border correctly
@ajtruckle
ajtruckle / MyStatic.cpp
Created January 31, 2025 12:59
Support MFC Group Box Control in Dark Mode
#include "pch.h"
#include "MyStatic.h"
BEGIN_MESSAGE_MAP(CMyStatic, CStatic)
ON_WM_PAINT()
END_MESSAGE_MAP()
void CMyStatic::OnPaint() {
CPaintDC dc(this); // Device context for painting