如:让qq弹出啦
解决方案 »
- 系统分析员面试题:云台的web远程控制问题!
- MFC高手请入:关于MFC对象(派生于CObject)必须在创建线程中使用的问题?
- 为什么对话框第一次运行,tooltip不显示.而关闭对话框,再次打开tooltip又能显示.
- GDI绘制的图形如何进行闪烁?
- ReadFile函数的问题!
- 如何限定一个切分窗口的一个窗口类的可调大小?
- 大家好,我来指点迷津了
- 两台电脑通过蓝牙以串口方式通讯 连接不上
- 如何把“c:\temp\test.txt”变成“c:\\temp\\test.txt”
- vc怎么打开.ply文件?
- CFile类 Copy.Open(__argv[0],CFile::modeRead)在WIN98下怎么老提示错误啊?
- 为什么曾经用APPWIZARD生成的。CPP文件再次用VC打开的时候在工作空间里找不到RESOURSE VIEW?还有即使打开了。RC文件,做了修改也是没有
m_tnid.cbSize=sizeof(NOTIFYICONDATA);
m_tnid.hWnd=this->m_hWnd;
m_tnid.uFlags=NIF_MESSAGE|NIF_ICON|NIF_TIP;
m_tnid.uCallbackMessage=MYWM_NOTIFYICON;
//用户定义的回调消息 m_tnid.uID=IDR_MAINFRAME;
HICON hIcon;
hIcon=AfxGetApp()->LoadIcon(IDR_MAINFRAME);
m_tnid.hIcon=hIcon;
::Shell_NotifyIcon(NIM_ADD,&m_tnid);
http://www.vckbase.com/document/viewdoc.asp?id=492
http://www.vckbase.com/document/viewdoc.asp?id=495
http://www.vckbase.com/document/viewdoc.asp?id=498
{
//AfxMessageBox("OK");
if (LOWORD(lParam) == WM_LBUTTONDBLCLK) //双击时。
{//这里是我的对话框程序
::ShowWindow(AfxGetApp()->GetMainWnd()->m_hWnd,SW_SHOW);
}
}
在做托盘时用zhaowenlong(文龙)那种方法,在左击图标时弹出原始窗口,右击图标弹出浮动菜单。
在view中增加消息处理函数如下:
LRESULT CxxView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
// TODO: Add your specialized code here and/or call the base class
switch (message)
{
case MYWM_NOTIFYICON:
if (lParam == WM_LBUTTONDOWN)
{
((CFrameWnd*)AfxGetMainWnd())->ShowWindow(SW_SHOW);
((CFrameWnd*)AfxGetMainWnd())->ShowWindow(SW_RESTORE);
}
else if (lParam == WM_RBUTTONDOWN)
{
AfxGetMainWnd()->SetForegroundWindow(); //弹出Popup菜单
CMenu menu;
menu.LoadMenu(IDR_MAINFRAME);
CMenu* pPopup=menu.GetSubMenu(0);
CPoint Point;
GetCursorPos(&Point);
pPopup->TrackPopupMenu(TPM_LEFTALIGN,Point.x,Point.y,AfxGetMainWnd(),NULL );
AfxGetMainWnd()->PostMessage(WM_NULL, 0, 0);
}
break;
default:
break;
} return CFormView::WindowProc(message, wParam, lParam);
}
回调函数
LRESULT CTrayNotifyIcon::OnTrayNotification(WPARAM wID, LPARAM lEvent)
{
//Return quickly if its not for this tray icon
if (wID != m_NotifyIconData.uID)
return 0L; //As a default action use a menu resource with the same id
//as this was created with
CMenu menu;
if (!menu.LoadMenu(m_NotifyIconData.uID))
return 0; CMenu* pSubMenu = menu.GetSubMenu(0);
if (!pSubMenu)
return 0; if (lEvent == WM_RBUTTONUP)
{
//Clicking with right button brings up a context menu // Make first menu item the default (bold font)
::SetMenuDefaultItem(pSubMenu->m_hMenu, 0, TRUE); //Display and track the popup menu
CPoint pos;
GetCursorPos(&pos);
::SetForegroundWindow(m_NotifyIconData.hWnd);
::TrackPopupMenu(pSubMenu->m_hMenu, 0, pos.x, pos.y, 0, m_NotifyIconData.hWnd, NULL); }
else if (lEvent == WM_LBUTTONDBLCLK)
{
// double click received, the default action is to execute first menu item
::SendMessage(m_NotifyIconData.hWnd, WM_COMMAND, pSubMenu->GetMenuItemID(0), 0);
} return 1; // handled
}