TrayNotify.cpp
资源名称:网络视频电话系统.rar [点击查看]
上传用户:oldpeter23
上传日期:2013-01-09
资源大小:1111k
文件大小:5k
源码类别:
IP电话/视频会议
开发平台:
Visual C++
- /*------------------------------------------------------------------------------*
- =============================
- 模块名称: TrayNotify.cpp
- =============================
- [目的]
- 方便任务栏托盘区图标的使用.
- [描述]
- 这是一个封装了任务栏托盘区图标所有操作的类,有了它就可以很方便地控制任务栏
- 托盘区图标。
- [用法]
- 这个模块用法很简单,我想用不着更多的说明. :-)
- [依赖性]
- 无
- [修改记录]
- 日期: 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;
- }
- //文件尾