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

📄 notify.cpp

📁 VisualBasic源码-游戏编程
💻 CPP
字号:
// Notify.cpp : implementation file
//

#include "stdafx.h"
#include "clock.h"
#include "Notify.h"

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

/////////////////////////////////////////////////////////////////////////////
// CNotify
#define WM_NOTIFYICON (WM_APP+100)
IMPLEMENT_DYNCREATE(CNotify, CCmdTarget)

CNotify::CNotify()
{
	m_nid.cbSize=sizeof(NOTIFYICONDATA);
}

CNotify::~CNotify()
{
}


BEGIN_MESSAGE_MAP(CNotify, CCmdTarget)
	//{{AFX_MSG_MAP(CNotify)
	//ON_MESSAGE(WM_NOTIFYICON,OnNotifyIcon)
		// NOTE - the ClassWizard will add and remove mapping macros here.
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CNotify message handlers

void CNotify::SetMsg(UINT uMsg)
{
	m_nid.uCallbackMessage=uMsg;
}
void CNotify::SetHwnd(HWND hw, UINT uFlags)
{
    m_nid.hWnd=hw;
	m_nid.uFlags=uFlags;
}

void CNotify::SetIcon(UINT uId, HICON hicon,char *tip)
{
    m_nid.uID=uId;
	m_nid.hIcon=hicon;
	strcpy(m_nid.szTip,tip);
}

BOOL CNotify::Shell_NotifyIcon(DWORD dwMessage, NOTIFYICONDATA nid)
{  
    return ::Shell_NotifyIcon(dwMessage,&nid);
}
LRESULT CNotify::OnNotifyIcon(WPARAM wParam, LPARAM lParam)
{
	
    if((UINT)wParam!=m_nid.uID)
		return 0;
	CMenu menu;
	if(!menu.LoadMenu(m_nid.uID))
		return 0;
	CMenu*pMenu=menu.GetSubMenu(0);
	if(!pMenu)
		return 0;
	CPoint point;
	GetCursorPos(&point);
    switch((UINT)lParam)
	{
	case WM_LBUTTONDBLCLK:
		::ShowWindow(m_nid.hWnd,SW_SHOW);
	    //MessageBox(m_nid.hWnd,"不明白 ","error",MB_OK);
		break;
	case WM_RBUTTONUP:
		::SetMenuDefaultItem(pMenu->m_hMenu, 0, TRUE);
		::SetForegroundWindow(m_nid.hWnd);
		//使特定的窗口变成前景窗,并使线程获得更高的优先级
		::TrackPopupMenu(pMenu->m_hMenu, 0, point.x, point.y, 0,
			m_nid.hWnd, NULL);
		//MessageBox(m_nid.hWnd,"不明白 ","error",MB_OK);
		break;
	}
}

⌨️ 快捷键说明

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