Skip to content

Commit

Permalink
check task bar icon
Browse files Browse the repository at this point in the history
Signed-off-by: Yuri Benditovich <[email protected]>
  • Loading branch information
ybendito committed Nov 9, 2024
1 parent 1677c3e commit b8cade4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
22 changes: 20 additions & 2 deletions SpiceRunner/CTaskBarIcon.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,30 @@ class CTaskBarIcon
wcscpy_s(m_Data.szTip, InitialName);
m_Data.uCallbackMessage = m_Message;
m_TaskBarMessage = RegisterWindowMessage(TEXT("TaskbarCreated"));
Log("TaskbarCreated message = %d", m_TaskBarMessage);
}
~CTaskBarIcon()
{
}
void Attach()
{
Log("%s", __FUNCTION__);
m_Data.hWnd = m_Parent.GetWindowHandle();
Op(NIM_ADD);
Op(NIM_SETVERSION);
}
void Detach()
{
Log("%s", __FUNCTION__);
Op(NIM_DELETE);
}
void ProcessIconMessage(UINT message, WPARAM wParam, LPARAM lParam)
{
if (message == WM_TIMER && !CheckIcon()) {
Detach();
Attach();
return;
}
if (m_TaskBarMessage && message == m_TaskBarMessage) {
Detach();
Attach();
Expand Down Expand Up @@ -76,14 +84,24 @@ class CTaskBarIcon
UINT m_Message;
UINT m_TaskBarMessage;
bool m_IconActive = false;
void Op(UINT operation)
bool Op(UINT operation)
{
Shell_NotifyIcon(operation, &m_Data);
bool b = Shell_NotifyIcon(operation, &m_Data);
if (!b) {
Log("%s: error on operation %d", __FUNCTION__, operation);
}
return b;
}
bool IsIconMessage(UINT msg)
{
return msg == m_Data.uCallbackMessage;
}
bool CheckIcon()
{
bool b = Op(NIM_MODIFY);
Log("%s: result %d", __FUNCTION__, b);
return b;
}
class BooleanHolder
{
public:
Expand Down
5 changes: 4 additions & 1 deletion SpiceRunner/SpiceRunnerDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ BOOL CSpiceRunnerDlg::OnInitDialog()
m_Icon.Attach();

LoadServers();
return TRUE; // return TRUE unless you set the focus to a control

SetTimer(1, 10000, NULL);

return TRUE; // return TRUE unless you set the focus to a control
}

// If you add a minimize button to your dialog, you will need the code below
Expand Down

0 comments on commit b8cade4

Please sign in to comment.