You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
2.5 KiB
C++

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

//////////////////////////////////////////////////////////////////////////
// Class Name: SShellNotifyIcon
// Description:show ShellNotifyIcon
// Creator: 359501300
// Version: 2014.9.19 - 1.0 - Create
//////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "SShellNotifyIcon.h"
SShellNotifyIcon::SShellNotifyIcon()
{
memset(&nid,0,sizeof(nid));
}
SShellNotifyIcon::~SShellNotifyIcon()
{
Hide();
}
void SShellNotifyIcon::Create(HWND hOwner,HICON hIcon,UINT uFlags, UINT uCallbackMessage, UINT uId, LPCSTR szTip)
{
IniNotifyIconData(hOwner,hIcon,uFlags, uCallbackMessage, uId, szTip);
}
BOOL SShellNotifyIcon::Show()
{
//未初使化NotifyIconData
if (nid.cbSize != sizeof(NOTIFYICONDATA))
return FALSE;
return Shell_NotifyIcon(NIM_ADD, &nid);
}
BOOL SShellNotifyIcon::Hide()
{
return Shell_NotifyIcon(NIM_DELETE, &nid);
}
void SShellNotifyIcon::IniNotifyIconData(HWND hOwner,HICON hIcon,UINT flags, UINT callbackmsg, UINT ID, LPCSTR szTip)
{
nid.cbSize = sizeof(NOTIFYICONDATA);
nid.hWnd = hOwner;
nid.uID = ID;
nid.uFlags = flags;//NIF_ICON | NIF_MESSAGE | NIF_TIP;
nid.uCallbackMessage = callbackmsg;
nid.hIcon = hIcon;
//_tcscpy_s(nid.szTip, szTip);
strcpy(nid.szTip,szTip);
}