虚心求教,如何控制弹出的MENU的位置。比如说向上弹出。

fanged 2003-10-16 12:16:55
如题,谢谢。
...全文
123 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
daylight1980 2003-10-16
  • 打赏
  • 举报
回复
BOOL TrackPopupMenu( UINT nFlags, int x, int y, CWnd* pWnd, LPCRECT lpRect = NULL );

lpRect 与此有关
yanw0212 2003-10-16
  • 打赏
  • 举报
回复
CMenu menu;
menu.LoadMenu(IDR_MENU3);
CPoint point ;
::GetCursorPos(&point);
::SetForegroundWindow(m_hWnd);// m_hWnd父窗口的句柄
menu.GetSubMenu(0)->TrackPopupMenu( TPM_LEFTALIGN,point.x,point.y,this,NULL);
wuxfBrave 2003-10-16
  • 打赏
  • 举报
回复
BOOL TrackPopupMenu( UINT nFlags, int x, int y, CWnd* pWnd, LPCRECT lpRect = NULL );

nFlags设置下列值
TPM_CENTERALIGN
If this flag is set, the function centers the shortcut menu horizontally relative to the coordinate specified by the x parameter.
TPM_LEFTALIGN
If this flag is set, the function positions the shortcut menu so that its left side is aligned with the coordinate specified by the x parameter.
TPM_RIGHTALIGN
Positions the shortcut menu so that its right side is aligned with the coordinate specified by the x parameter.
Use one of the following flags to specify how the function positions the shortcut menu vertically.
TPM_BOTTOMALIGN
If this flag is set, the function positions the shortcut menu so that its bottom side is aligned with the coordinate specified by the y parameter.
TPM_TOPALIGN
If this flag is set, the function positions the shortcut menu so that its top side is aligned with the coordinate specified by the y parameter.
TPM_VCENTERALIGN
beyondtkl 2003-10-16
  • 打赏
  • 举报
回复
CRect Rect;
GetDlgItem(IDC_BTN_MAIN_SYSTEM_MENU)->GetWindowRect(&Rect);
m_MainMenu.GetSubMenu(2)->TrackPopupMenu(TPM_RIGHTBUTTON|TPM_LEFTALIGN,Rect.TopLeft().x,Rect.TopLeft().y,this);

** Rect.TopLeft().x,Rect.TopLeft().y
这两个参数就是表示:
在这个矩形的左上方,即在举行的最上面弹出

15,979

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧