//加载"选择"右键菜单
CMenu menu;
menu.LoadMenu(IDR_MENU1); CMenu* pPopupMenu=menu.GetSubMenu(0);
CPoint pt;
GetCursorPos(&pt);<<<<<<<<<<<<<<<<<注意本行
pPopupMenu->TrackPopupMenu(TPM_RIGHTBUTTON,pt.x,pt.y,this);
//菜单弹出后销毁对象
menu.DestroyMenu();
pPopupMenu->DestroyMenu();
pPopupMenu=NULL;
CMenu menu;
menu.LoadMenu(IDR_MENU1); CMenu* pPopupMenu=menu.GetSubMenu(0);
CPoint pt;
GetCursorPos(&pt);<<<<<<<<<<<<<<<<<注意本行
pPopupMenu->TrackPopupMenu(TPM_RIGHTBUTTON,pt.x,pt.y,this);
//菜单弹出后销毁对象
menu.DestroyMenu();
pPopupMenu->DestroyMenu();
pPopupMenu=NULL;
解决方案 »
- unresolved external symbol "public: virtual struct CRuntimeClass * __thiscall CTrayTimerWnd::GetRuntimeClass(void)const " (?
- 发送汉字内码
- 静态拆分窗口后, VIEW收不到菜单命令,求帮助
- 如何在Unicode 环境下判断 字符是 英数 还是中文呢?
- CSize能改变么??
- 急!急需ADO操作数据库的封装类!
- 关于重载运算符<<,在线等!!!!!
- 为什么老是出现"函数非法定义"这样的错误
- 来看看这个!
- 请教如何在程序中动态的生成一个CDaoRecordSet类?而不用ClassWizard?
- 那位有电子工业出版社的《21天学通WINDOWS编程》的配书源代码,愿意以好东东交换。
- _T,TEXT,_TEXT,L,etc.
// application window and displays it as a floating popup menu
// when the right mouse button is clicked in view.
// CMyView is a CView-derived class.
void CMyView::OnRButtonDown(UINT nFlags, CPoint point)
{
CView::OnRButtonDown(nFlags, point); CMenu* menu_bar = AfxGetMainWnd()->GetMenu();
CMenu* file_menu = menu_bar->GetSubMenu(0);
ASSERT(file_menu); file_menu->TrackPopupMenu(TPM_LEFTALIGN |TPM_RIGHTBUTTON, point.x,
point.y, this);
}msdn的例子
我忘了传进来的point是否屏幕坐标.如果是客户区坐标
那就ClientToScreen(&pt);因为 TrackPopupMenu(TPM_RIGHTBUTTON,pt.x,pt.y,this);
里的x和y是屏幕坐标
xSpecifies the horizontal position in screen coordinates of the pop-up menu. Depending on the value of the nFlags parameter, the menu can be left-aligned, right-aligned, or centered relative to this position.ySpecifies the vertical position in screen coordinates of the top of the menu on the screen.