最小化后,不在任务栏上,像QQ一样,怎么实现,大家一起聊!
解决方案 »
- mfc单文档界面拆分问题
- 关于codeproject的ADO类
- VFW关于视频捕获卡的问题
- 我想我的程序在关机的时候做一些事``应该捕获哪个消息?
- 关于画图的,为什么我画不上去???
- 程序在开发环境下可以,在实际环境运行2、3天后出错(Visual C++ Runtime Library)
- 一个VC生成的.exe文件,我想反汇编后修改它,不知道怎么弄??有什么方法?
- 某CPropertyPage页在第一次点击时会初始化,但我现在想在以后的用户切换时得到切换消息,是哪个消息?
- 谁会用VC解这道题?
- 【新年呈献】高性能 Socket 组件 HP-Socket v3.1.2 正式发布
- 初学者的问题:为什么要自己来显示指定数据结构的大小?谢谢!
- 求助 画图的问题 在Doc中保存时出错
DWORD dwMessage,
PNOTIFYICONDATA pnid
);typedef struct _NOTIFYICONDATA {
DWORD cbSize;
HWND hWnd;
UINT uID;
UINT uFlags;
UINT uCallbackMessage;
HICON hIcon;
char szTip[64];
} NOTIFYICONDATA, *PNOTIFYICONDATA;
Contains information that the system needs to process taskbar status area messages. cbSize
Size of this structure, in bytes.
hWnd
Handle to the window that will receive notification messages associated with an icon in the taskbar status area.
uID
Application-defined identifier of the taskbar icon.
uFlags
Array of flags that indicate which of the other members contain valid data. This member can be a combination of the following: NIF_ICON The hIcon member is valid.
NIF_MESSAGE The uCallbackMessage member is valid.
NIF_TIP The szTip member is valid. uCallbackMessage
Application-defined message identifier. The system uses this identifier for notification messages that it sends to the window identified in hWnd. These notifications are sent when a mouse event occurs in the bounding rectangle of the icon.
hIcon
Handle to the icon to add, modify, or delete.
szTip
Tooltip text to display for the icon.
DWORD dwMessage,
PNOTIFYICONDATA pnid
); Sends a message to the system to add, modify, or delete an icon from the taskbar status area. Returns nonzero if successful, or zero otherwise.
dwMessage
Message value to send. This parameter can be one of these values: NIM_ADD Adds an icon to the status area.
NIM_DELETE Deletes an icon from the status area.
NIM_MODIFY Modifies an icon in the status area. pnid
Address of a NOTIFYICONDATA structure. The content of the structure depends on the value of dwMessage.
第一点,你要实现NotifyIcon.
第二点,你要实现删除在TASKBAR上删除.http://www.codediy.com/codebbs/index.asp
{
// TODO: Add your specialized code here and/or call the base class
if(message==WM_USER )
{
if(lParam==WM_RBUTTONDOWN)
{
CMenu menu,*pSubMenu;
menu.LoadMenu(IDR_MENU1);
pSubMenu=menu.GetSubMenu(m_idIcon);
POINT pt;
GetCursorPos(&pt);
pSubMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON,pt.x,pt.y,this);
}
}
return CFrameWnd::WindowProc(message, wParam, lParam);
}2 m_nid.cbSize=sizeof(NOTIFYICONDATA);
m_nid.hWnd=m_hWnd;
m_nid.uID=0;
m_nid.uCallbackMessage=WM_USER;
m_nid.hIcon=AfxGetApp()->LoadIcon(IDI_ICON1);
::lstrcpy(m_nid.szTip,"Hello");
m_nid.uFlags=NIF_ICON | NIF_MESSAGE | NIF_TIP;
//以上为初始化结构
m_idIcon=0;
::Shell_NotifyIcon(NIM_ADD,&m_nid); //加图标,并在析构函数中删除
::DestroyIcon(m_nid.hIcon);
2 Create中
具体步骤见《Visual C++ MFC扩展编程实例》P79 实例5,可惜我的光盘丢了
2、删除添加图标 Shell_NotifyIcon(NIM_DELETE,&m_nid);
3、要调用函数以收到托盘通告 SetNotification(CWnd* pNotifyWnd,UINT uCbMsg);
4、处理消息 LRESULT OnTrayNotification(WPARAM uid, LPARAM lEvent);
在此函数中处理mouse右键点击后弹出菜单(调用::TrackPopupMemu(youmenu.m_hyoumenu,0,mouse.x,mouse.y,0,m_hWnd,NULL);
SetWindowLong(m_hWnd,GWL_EXSTYLE,WS_EX_TOOLWINDOW);呵呵
void CMainFrame::OnShow()
{
// TODO: Add your command handler code here
ShowWindow(SW_SHOW);
}
void CMainFrame::OnHide()
{
// TODO: Add your command handler code here
ShowWindow(SW_HIDE);
}void CMainFrame::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
if(m_idIcon==0)
{
m_nid.hIcon=AfxGetApp()->LoadIcon(IDI_ICON2);
m_idIcon=1;
}
else
{
m_nid.hIcon=::LoadIcon(AfxGetResourceHandle(),MAKEINTRESOURCE(IDI_ICON1));
m_idIcon=0;
}
::Shell_NotifyIcon(NIM_MODIFY,&m_nid);
::DestroyIcon(m_nid.hIcon);
CFrameWnd::OnTimer(nIDEvent);
}
CREATE 中 SetTimer(0,2000,NULL);
对于QQ在任务栏托盘区的图标和菜单,可参阅nustchenhf() 的帖子。