Skip to content

Commit ae18b94

Browse files
author
smith
committed
only show notification icon when starting minimized
* also added /min argument for command line usage
1 parent 518fa50 commit ae18b94

File tree

3 files changed

+33
-17
lines changed

3 files changed

+33
-17
lines changed

audio-router-gui/main.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,16 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
124124
MessageBox(NULL, L"Could not create window. Audio Router will close.", NULL, MB_ICONERROR);
125125
goto cleanup;
126126
}
127-
win.ShowWindow(nCmdShow);
128-
win.UpdateWindow();
127+
128+
if (SW_SHOWMINNOACTIVE == nCmdShow || strcmp(lpCmdLine, "/min") == 0) {
129+
win.ShowWindow(SW_HIDE);
130+
win.addTrayIcon();
131+
win.UpdateWindow();
132+
}
133+
else {
134+
win.ShowWindow(nCmdShow);
135+
win.UpdateWindow();
136+
}
129137

130138
while(GetMessage(&msg, NULL, 0, 0) > 0)
131139
{

audio-router-gui/window.cpp

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,7 @@ LRESULT window::OnSysCommand(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHan
4747
}
4848
}*/
4949

50-
if (!m_NotifyIconData.cbSize)
51-
{
52-
m_NotifyIconData.cbSize = NOTIFYICONDATAA_V1_SIZE;
53-
m_NotifyIconData.hWnd = m_hWnd;
54-
m_NotifyIconData.uID = 1;
55-
m_NotifyIconData.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
56-
m_NotifyIconData.uCallbackMessage = WM_SYSTEMTRAYICON;
57-
m_NotifyIconData.hIcon = AtlLoadIconImage(IDR_MAINFRAME, LR_DEFAULTCOLOR, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON));
58-
ATL::CString sWindowText;
59-
GetWindowText(sWindowText);
60-
_tcscpy_s(m_NotifyIconData.szTip, sWindowText);
61-
}
62-
63-
Shell_NotifyIcon(NIM_ADD, &m_NotifyIconData);
50+
this->addTrayIcon();
6451
ShowWindow(SW_HIDE);
6552

6653
bHandled = TRUE;
@@ -119,6 +106,26 @@ LRESULT window::OnSystemTrayExit(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWnd
119106
return 0;
120107
}
121108

109+
int window::addTrayIcon()
110+
{
111+
if (!m_NotifyIconData.cbSize)
112+
{
113+
m_NotifyIconData.cbSize = NOTIFYICONDATAA_V1_SIZE;
114+
m_NotifyIconData.hWnd = m_hWnd;
115+
m_NotifyIconData.uID = 1;
116+
m_NotifyIconData.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
117+
m_NotifyIconData.uCallbackMessage = WM_SYSTEMTRAYICON;
118+
m_NotifyIconData.hIcon = AtlLoadIconImage(IDR_MAINFRAME, LR_DEFAULTCOLOR, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON));
119+
ATL::CString sWindowText;
120+
GetWindowText(sWindowText);
121+
_tcscpy_s(m_NotifyIconData.szTip, sWindowText);
122+
}
123+
124+
Shell_NotifyIcon(NIM_ADD, &m_NotifyIconData);
125+
126+
return 0;
127+
}
128+
122129
LRESULT window::OnFileRefreshlist(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
123130
{
124131
if(!this->dlg_main_b)
@@ -132,7 +139,7 @@ LRESULT window::OnFileRefreshlist(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWn
132139
LRESULT window::OnAbout(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
133140
{
134141
this->MessageBoxW(
135-
L"Audio Router version 0.10.4.\n" \
142+
L"Audio Router version 0.10.5.\n" \
136143
L"\nIf you come across any bugs(especially relating to routing or duplicating), " \
137144
L"or just have an idea for a new feature, " \
138145
L"please open an issue on github: github.com/a-sync/audio-router/",

audio-router-gui/window.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,5 @@ class window : public CFrameWindowImpl<window>
5757
LRESULT OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled);
5858
LRESULT OnSystemTrayIcon(UINT, WPARAM wParam, LPARAM lParam);
5959
LRESULT OnRestore(UINT, INT, HWND);
60+
int addTrayIcon();
6061
};

0 commit comments

Comments
 (0)