I like mini mode/full mode for main frame like TitlebarFrame sample, and I like dark/light mode switching like darkmode sample. I want to leverage dark mode support for mini/full mode. How can I?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
For the most part, the DarkMode sample differs from the Frame sample in that it overrides CFrame::OnSysColorChange and CFrame::SetTheme, and adds SetDarkTheme.
You should be able to modify the TitlebarFrame sample to support dark mode by copying code from the DarkMode sample.
The following guide might prove useful.
1) Start with a copy of the TitlebarFrame sample. Its best to use the most recent TitlebarFrame available from the code snapshot from SourceForge.
2) Add the following files from the DarkMode sample to your project:
- DarkAbout.h
- DarkAbout.cpp
- DarkMode.h
- DarkMode.cpp
- DarkPreview.h
3) Add the following functions from the DarkMode sample:
- CMainFrame::OnHelp
- CMainFrame::OnSysColorChange
- CMainFrame::SetDarkTheme
- CMainFrame::SetTheme
4) Remove the ::DwmSetWindowAttribute function from CMainFrame::OnSysColorChange
5) Add the following private members to CMainFrame:
CDarkPreview<cview> m_preview;
CDarkAbout m_helpDialog;</cview>
6) Add the following to MainFrame.h
#include "DarkAbout.h"
#include "DarkPreview.h"
7) Add the following to MainFrame.cpp
#include "DarkMode.h"
8) The code should now compile and detect dark mode. You will need to tweak the colors for darkmode in:
- CMainFrame::DrawTitleText
- CMainFrame::DrawBackground
- CMainFrame::DrawCloseButton
- CMainFrame::DrawMinimizeButton
- CMainFrame::DrawMaximizeButton
Best regards,
David
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I like mini mode/full mode for main frame like TitlebarFrame sample, and I like dark/light mode switching like darkmode sample. I want to leverage dark mode support for mini/full mode. How can I?
Hi Kite,
For the most part, the DarkMode sample differs from the Frame sample in that it overrides CFrame::OnSysColorChange and CFrame::SetTheme, and adds SetDarkTheme.
You should be able to modify the TitlebarFrame sample to support dark mode by copying code from the DarkMode sample.
The following guide might prove useful.
1) Start with a copy of the TitlebarFrame sample. Its best to use the most recent TitlebarFrame available from the code snapshot from SourceForge.
2) Add the following files from the DarkMode sample to your project:
- DarkAbout.h
- DarkAbout.cpp
- DarkMode.h
- DarkMode.cpp
- DarkPreview.h
3) Add the following functions from the DarkMode sample:
- CMainFrame::OnHelp
- CMainFrame::OnSysColorChange
- CMainFrame::SetDarkTheme
- CMainFrame::SetTheme
4) Remove the ::DwmSetWindowAttribute function from CMainFrame::OnSysColorChange
5) Add the following private members to CMainFrame:
CDarkPreview<cview> m_preview;
CDarkAbout m_helpDialog;</cview>
6) Add the following to MainFrame.h
#include "DarkAbout.h"
#include "DarkPreview.h"
7) Add the following to MainFrame.cpp
#include "DarkMode.h"
8) The code should now compile and detect dark mode. You will need to tweak the colors for darkmode in:
- CMainFrame::DrawTitleText
- CMainFrame::DrawBackground
- CMainFrame::DrawCloseButton
- CMainFrame::DrawMinimizeButton
- CMainFrame::DrawMaximizeButton
Best regards,
David
Got it. Thanks!