shellicon.cpp

来自「使用Socket和多线程技术实现远程通信」· C++ 代码 · 共 71 行

CPP
71
字号
// ShellIcon.cpp: implementation of the CShellIcon class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "ShellIcon.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CShellIcon::CShellIcon()
{

}
//////////////////////////////////////////////////////////////////////
//	功能:	构造函数
//	参数:
//		pMainWnd:	主窗口;
//		hIcon	:	在任务栏上显示的图标句柄
//		strTip	:	当鼠标位于其上显示的提示文本
//	返回值:	无
//////////////////////////////////////////////////////////////////////
CShellIcon::CShellIcon(CWnd* pMainWnd,HICON hIcon, UINT uMsg, CString strTip )
{
	m_pMainWnd  = pMainWnd;
	m_hIcon		= hIcon;
	m_strTip	= strTip;
	m_uMsg		= uMsg;

}

CShellIcon::~CShellIcon()
{

}

void CShellIcon::AddIcon()
{
	memset(&m_tndData,0,sizeof(NOTIFYICONDATA));
	m_tndData.cbSize	= sizeof(NOTIFYICONDATA);
	m_tndData.hIcon		= m_hIcon;
	m_tndData.hWnd		= m_pMainWnd->m_hWnd;
	m_tndData.uFlags	= NIF_ICON|NIF_MESSAGE|NIF_TIP;
	m_tndData.uID		= 101;
	m_tndData.uCallbackMessage  = m_uMsg;
	_tcscpy(m_tndData.szTip,m_strTip);

	Shell_NotifyIcon(NIM_ADD,&m_tndData);
}

void CShellIcon::DeleteIcon()
{
	m_tndData.uFlags = NIF_ICON;
	Shell_NotifyIcon(NIM_DELETE,&m_tndData);
}

void CShellIcon::Init(CWnd* pMainWnd,UINT uMsg, CString strTip, HICON hIcon)
{
	m_pMainWnd	 = pMainWnd;
	m_hIcon		 = hIcon;
	m_uMsg		 = uMsg;
	m_strTip	 = strTip;
}

⌨️ 快捷键说明

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