Skip to content

Commit

Permalink
System Icon turn gray when app inactive
Browse files Browse the repository at this point in the history
  • Loading branch information
lededev committed Nov 18, 2024
1 parent 861ee28 commit fa6650d
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Src/Common/MDITabBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,6 @@ void CMDITabBar::OnPaint()
if (!m_bOnTitleBar)
return __super::OnPaint();
CPaintDC dc(this);
m_titleBar.DrawIcon(AfxGetMainWnd(), dc);
m_titleBar.DrawIcon(AfxGetMainWnd(), dc, m_tabCtrl.GetActive());
m_titleBar.DrawButtons(dc, CTitleBarHelper::GetTextColor(m_tabCtrl.GetActive()), m_tabCtrl.GetBackColor());
}
1 change: 1 addition & 0 deletions Src/Merge2.rc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// remains consistent on all systems.

IDR_MAINFRAME ICON "res\\Merge.ico"
IDR_MAINFRAME_ICON_GRAY ICON "res\\Merge_gray.ico"
IDR_MERGEPROJECT ICON "res\\MergeProject.ico"
IDR_MERGEDOCTYPE ICON "res\\MergeDoc.ico"
IDR_DIRDOCTYPE ICON "res\\MergeDir.ico"
Expand Down
8 changes: 4 additions & 4 deletions Src/TitleBarHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,18 @@ CTitleBarHelper::CTitleBarHelper()
void CTitleBarHelper::Init(CWnd *pWnd)
{
m_pWnd = pWnd;
m_icon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
m_icon_gray = AfxGetApp()->LoadIcon(IDR_MAINFRAME_ICON_GRAY);
}

int CTitleBarHelper::GetTopMargin() const
{
return 0;
}

void CTitleBarHelper::DrawIcon(CWnd* pWnd, CDC& dc)
void CTitleBarHelper::DrawIcon(CWnd* pWnd, CDC& dc, bool active)
{
HICON hIcon = (HICON)pWnd->SendMessage(WM_GETICON, ICON_SMALL2, 0);
if (hIcon == nullptr)
hIcon = (HICON)GetClassLongPtr(pWnd->m_hWnd, GCLP_HICONSM);
HICON hIcon = active ? m_icon : m_icon_gray;
if (hIcon == nullptr)
return;
const int topMargin = GetTopMargin();
Expand Down
4 changes: 3 additions & 1 deletion Src/TitleBarHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class CTitleBarHelper {
public:
CTitleBarHelper();
void Init(CWnd* pWnd);
void DrawIcon(CWnd* pWnd, CDC& dc);
void DrawIcon(CWnd* pWnd, CDC& dc, bool active);
void DrawButtons(CDC& dc, COLORREF textColor, COLORREF backColor);
int GetTopMargin() const;
int GetLeftMargin() const { return PointToPixel(m_leftMargin); }
Expand Down Expand Up @@ -51,4 +51,6 @@ class CTitleBarHelper {
unsigned m_nHitTest;
float m_leftMargin;
float m_rightMargin;
HICON m_icon;
HICON m_icon_gray;
};
Binary file added Src/res/Merge_gray.ico
Binary file not shown.
1 change: 1 addition & 0 deletions Src/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#define IDR_POPUP_PLUGIN_COMMAND_LINE_MENU 126
#define IDR_POPUP_PLUGIN_ADD_MENU 127
#define IDR_POPUP_DIRVIEW_COMPAREMETHOD 128
#define IDR_MAINFRAME_ICON_GRAY 129
#define IDD_ABOUTBOX 200
#define IDD_OPEN 202
#define IDD_SAVECLOSING 203
Expand Down

0 comments on commit fa6650d

Please sign in to comment.