分类: C/C++
2008-08-07 17:36:35
void CDemoDlg::OnFileDemo1() { ShowWindow(SW_SHOW); m_TrayIcon.RemoveIcon(); } void CDemoDlg::OnFileExit() { m_TrayIcon.RemoveIcon(); OnCancel(); }5、 在DemoDlg.cpp中自定义消息 #define WM_ICON_NOTIFY WM_USER 10,并在声明消息处声明消息处理函数:
BEGIN_MESSAGE_MAP(CDemoDlg, CDialog) ...... ON_MESSAGE(WM_ICON_NOTIFY, OnTrayNotification) …… END_MESSAGE_MAP()在类CDemoDlg中增加成员函数:
LRESULT OnTrayNotification(WPARAM wParam,LPARAM lParam);实现部分:
LRESULT CDemoDlg::OnTrayNotification(WPARAM wParam,LPARAM lParam) { return m_TrayIcon.OnTrayNotification(wParam,lParam); }6、 在对话框添加“开始”按扭,并双击“开始”按扭编辑处理程序:
void CDemoDlg::OnBnClickedButton1() { m_TrayIcon.Create(this,WM_ICON_NOTIFY,"鼠标指向时显示",m_hIcon,IDR_DEMO); //构造 ShowWindow(SW_HIDE); //隐藏窗口 }