⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 traynotify.cpp

📁 NetTalk是一个适用于局域网和因特网的可视电话软件 一.开发环境 Windows2000 Server & Visual C++6.0 & SDK +自开发的CWndX类库(相当于简化的MF
💻 CPP
字号:
/*------------------------------------------------------------------------------*\
 =============================
   模块名称: 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;
}

//文件尾

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -