I found another example called Enable a Dark mode title bar for Win32 applications from Microsoft, but my translated code still not work with vb6:
C++ code:
my VB6 code:Code:#ifndef DWMWA_USE_IMMERSIVE_DARK_MODE #define DWMWA_USE_IMMERSIVE_DARK_MODE 20 #endif BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) { hInst = hInstance; // Store instance handle in our global variable HWND hWnd = CreateWindowW(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, nullptr, nullptr, hInstance, nullptr); BOOL value = TRUE; ::DwmSetWindowAttribute(hWnd, DWMWA_USE_IMMERSIVE_DARK_MODE, &value, sizeof(value)); if (!hWnd) { return FALSE; } ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); return TRUE; }
I'm starting to think that Dark Mode isn't possible with VB6...Code:Private Declare Function DwmSetWindowAttribute Lib "dwmapi.dll" (ByVal HWND As Long, ByVal dwAttribute As Long, ByRef pvAttribute As Long, ByVal cbAttribute As Long) As Long Private Const DWMWA_USE_IMMERSIVE_DARK_MODE = 20 Private Sub Form_Load() Dim bValue As Long bValue = 1 Call DwmSetWindowAttribute(Me.hWnd, DWMWA_USE_IMMERSIVE_DARK_MODE, bValue, LenB(bValue)) End Sub




Reply With Quote
