如:让qq弹出啦
解决方案 »
- CImage怎么得到位图的大小,有什么函数没
- 修改xp sp2下raw socket遇到的问题
- 急救!急需C或者VC写的基本遗传算法代码,最好带函数实例!谢谢
- 求问:请大家帮下忙
- 如果给一个MFC向导生成的.exe文件改名
- jpeg问题
- 关于InstallShield,如何在程序卸载时删除注册表中的某些信息?
- 求助
- 我想在VC中用rdmsr指令 但需要运行在0级驱动模式 怎么做
- IOCP中无法得到GetQueuedCompletionStatus通知?
- 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
}