?? traynotify.cpp
字號:
/*------------------------------------------------------------------------------*\
=============================
模塊名稱: TrayNotify.cpp
=============================
//Download by http://www.codefans.net
[目的]
方便任務欄托盤區圖標的使用.
[描述]
這是一個封裝了任務欄托盤區圖標所有操作的類,有了它就可以很方便地控制任務欄
托盤區圖標。
[用法]
這個模塊用法很簡單,我想用不著更多的說明. :-)
[依賴性]
無
[修改記錄]
日期: 01-10-7
版本: 1.01
作者: Brant Q
備注:
[版權]
2000-2002 115軟件工廠 版權所有
[聲明]
\*------------------------------------------------------------------------------*/
#include <Windows.h>
#include "TrayNotify.h"
//由于該類實現比較簡單,很多東西在MSDN中一查便知,所以也就不在此多加注釋
/*---------------------------------------------------------------------------------
*/
CTrayNotify::CTrayNotify()
{
memset((void*)&m_nid,0,sizeof(m_nid));
m_nid.cbSize=sizeof(m_nid);
m_bShow=FALSE;
}
/*---------------------------------------------------------------------------------
*/
CTrayNotify::~CTrayNotify()
{
ShowIcon(FALSE);
}
/*---------------------------------------------------------------------------------
*/
void CTrayNotify::SetIcon(const HICON hIcon,BOOL bEnable)
{
m_nid.hIcon=hIcon;
if(bEnable)
m_nid.uFlags|=NIF_ICON;
}
/*---------------------------------------------------------------------------------
*/
HICON CTrayNotify::GetIcon() const
{
return m_nid.hIcon;
}
/*---------------------------------------------------------------------------------
*/
void CTrayNotify::SetMsg(UINT uMsg,BOOL bEnable)
{
m_nid.uCallbackMessage=uMsg;
if(bEnable)
m_nid.uFlags|=NIF_MESSAGE;
}
/*---------------------------------------------------------------------------------
*/
UINT CTrayNotify::GetMsg()
{
return m_nid.uCallbackMessage;
}
/*---------------------------------------------------------------------------------
*/
void CTrayNotify::SetTip(const char *szTip,BOOL bEnable)
{
lstrcpyn(m_nid.szTip,szTip,sizeof(m_nid.szTip));
if(bEnable)
m_nid.uFlags|=NIF_TIP;
}
/*---------------------------------------------------------------------------------
*/
void CTrayNotify::GetTip(char *szTip,UINT uTxtLen) const
{
lstrcpyn(szTip,m_nid.szTip,uTxtLen);
}
/*---------------------------------------------------------------------------------
*/
BOOL CTrayNotify::SetHwnd(const HWND hWnd)
{
BOOL bRet=TRUE;
if(IsWindow(hWnd))
{
m_nid.hWnd=hWnd;
}
else
bRet=FALSE;
return bRet;
}
/*---------------------------------------------------------------------------------
*/
HWND CTrayNotify::GetHwnd() const
{
return m_nid.hWnd;
}
/*---------------------------------------------------------------------------------
*/
void CTrayNotify::SetID(const UINT uID)
{
m_nid.uID=uID;
}
/*---------------------------------------------------------------------------------
*/
UINT CTrayNotify::GetID() const
{
return m_nid.uID;
}
/*---------------------------------------------------------------------------------
*/
BOOL CTrayNotify::Refresh()
{
return Shell_NotifyIcon(NIM_MODIFY,&m_nid);
}
/*---------------------------------------------------------------------------------
*/
BOOL CTrayNotify::ShowIcon(BOOL bShow)
{
BOOL bRet=FALSE;
if(m_bShow)
{
if(!bShow)
{
bRet=Shell_NotifyIcon(NIM_DELETE,&m_nid);
}
}
else
{
if(bShow)
bRet=Shell_NotifyIcon(NIM_ADD,&m_nid);
}
if(bRet)
{
m_bShow=bShow;
}
return bRet;
}
/*---------------------------------------------------------------------------------
*/
BOOL CTrayNotify::Modify(const NOTIFYICONDATA& nid)
{
CopyMemory((void*)&m_nid,(void*)&nid,sizeof(nid));
return Shell_NotifyIcon(NIM_MODIFY,&m_nid);
}
/*---------------------------------------------------------------------------------
*/
void CTrayNotify::GetNid(NOTIFYICONDATA* pNid) const
{
CopyMemory((void*)pNid,(void*)&m_nid,sizeof(m_nid));
}
/*---------------------------------------------------------------------------------
*/
BOOL CTrayNotify::IsIconShow() const
{
return m_bShow;
}
/*---------------------------------------------------------------------------------
*/
void CTrayNotify::Reset()
{
ShowIcon(FALSE);
memset((void*)&m_nid,0,sizeof(m_nid));
}
/*---------------------------------------------------------------------------------
*/
void CTrayNotify::SetFlag(UINT uFlag)
{
m_nid.uFlags=uFlag;
}
/*---------------------------------------------------------------------------------
*/
UINT CTrayNotify::GetFlag() const
{
return m_nid.uFlags;
}
//文件尾
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -