?
void CPatControlDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
switch(nID)
{
case SC_MINIMIZE:
ShowWindow(SW_HIDE | SW_MINIMIZE | SW_SHOWMINIMIZED);
m_gdiobj.SetTaskIcon(this,m_hIcon,1,m_Log.GetFile().GetBuffer());
return;
break;
case SC_RESTORE:
if(IsIconic())
{
ShowWindow(SW_SHOW|SW_MAXIMIZE|SW_SHOWMAXIMIZED);
UpdateWindow();
m_gdiobj.SetTaskIcon(this,m_hIcon,0,m_Log.GetFile().GetBuffer());
return;
}
break;
}
CWnd::OnSysCommand(nID, lParam);
}
void CGdiObj::SetTaskIcon(CWnd *pWnd,HICON hIcon,short stat,char *pTitle /*=0*/)
{
if(pWnd)
{
if(stat)
{
memset(&m_iconize,0,sizeof(m_iconize));
m_iconize.cbSize = sizeof(m_iconize);
m_iconize.hIcon = (HICON)hIcon;
m_iconize.uID = WM_USER + (GetTickCount()%100);//more then one with same id dont work with tooltip
m_iconize.uFlags = NIF_ICON | NIF_TIP | NIF_MESSAGE;
m_iconize.hWnd = pWnd->m_hWnd;
m_iconize.uCallbackMessage = ICONIZED;
if(pTitle) strcpy(m_iconize.szTip,pTitle);
Shell_NotifyIcon(NIM_ADD, &m_iconize);
pWnd->ShowWindow(SW_HIDE);
}
else
{
Shell_NotifyIcon(NIM_DELETE, &m_iconize);
pWnd->ShowWindow(SW_RESTORE);
}
}
m_trayed = stat;
}
```cpp
void CGdiObj::UpdateTaskIcon(char *pTitle)
{
if (m_trayed && pTitle)
{
m_iconize.uFlags = NIF_TIP | NIF_MESSAGE;
strcpy(m_iconize.szTip, pTitle);
Shell_NotifyIcon(NIM_MODIFY, &m_iconize);
}
}