弱问题请教:关于右键快捷菜单

goodsong 2003-01-06 10:11:32
要让鼠标点在不同的区域出现不同的快捷菜单:就像VC一样
我重载了
void CMainFrame::OnContextMenu(CWnd* pWnd, CPoint point)
这样鼠标点在标题栏上时没了以前的缺省菜单,怎么办?
...全文
45 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
sinhighly 2003-01-13
  • 打赏
  • 举报
回复
up
goodsong 2003-01-09
  • 打赏
  • 举报
回复
我知道OnNcHitTest
但是获得的值如何用呢?
给个点在标题条上弹出系统菜单,点在工具栏上弹出另外的菜单的例子好吗?
谢了先!
反正我用OnContextMenu和OnNcHitTest是没有成功,也不知哪里搞错了
demetry 2003-01-08
  • 打赏
  • 举报
回复
CWnd::OnNcHitTest
HTBORDER In the border of a window that does not have a sizing border.


HTBOTTOM In the lower horizontal border of the window.


HTBOTTOMLEFT In the lower-left corner of the window border.


HTBOTTOMRIGHT In the lower-right corner of the window border.


HTCAPTION In a title-bar area.


HTCLIENT In a client area.


HTERROR On the screen background or on a dividing line between windows (same as HTNOWHERE except that the DefWndProc Windows function produces a system beep to indicate an error).


HTGROWBOX In a size box.


HTHSCROLL In the horizontal scroll bar.


HTLEFT In the left border of the window.


HTMAXBUTTON In a Maximize button.


HTMENU In a menu area.


HTMINBUTTON In a Minimize button.


HTNOWHERE On the screen background or on a dividing line between windows.


HTREDUCE In a Minimize button.


HTRIGHT In the right border of the window.


HTSIZE In a size box (same as HTGROWBOX).


HTSYSMENU In a Control menu or in a Close button in a child window.


HTTOP In the upper horizontal border of the window.


HTTOPLEFT In the upper-left corner of the window border.


HTTOPRIGHT In the upper-right corner of the window border.


HTTRANSPARENT In a window currently covered by another window.


HTVSCROLL In the vertical scroll bar.


HTZOOM In a Maximize button.
goodsong 2003-01-08
  • 打赏
  • 举报
回复
不行哦,给个例子吧。
snakeman22@sina.com
icelight 2003-01-07
  • 打赏
  • 举报
回复
楼上不是说了HitTest()吗?
goodsong 2003-01-07
  • 打赏
  • 举报
回复
很简单的问题,100分都没人要吗?
要是真没人知道,来者有分哦
hailong0108 2003-01-07
  • 打赏
  • 举报
回复
你最好去查一下清华的一本关于基础的书。 我看到过现在记不清了。
qhtqht 2003-01-06
  • 打赏
  • 举报
回复
我用这个--点在客户区的。
void CMDITestView::OnRButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
// TODO: Add your message handler code here and/or call default

CMenu menu;
VERIFY(menu.LoadMenu(IDR_POPUP_ONVIEW));

CMenu* pPopup = menu.GetSubMenu(0);
ASSERT(pPopup != NULL);

CWnd* pWndPopupOwner = this;
while (pWndPopupOwner->GetStyle() & WS_CHILD)
pWndPopupOwner = pWndPopupOwner->GetParent();

ClientToScreen(&point);

pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y,
pWndPopupOwner);


CView::OnRButtonUp(nFlags, point);
}
goodsong 2003-01-06
  • 打赏
  • 举报
回复
我要做的就是右键点在标题栏上弹出缺省菜单,
点在工具栏上弹出配置工具栏的菜单
点在客户区弹出绘图用的快捷菜单

不知道分别重载哪个函数,请问怎样做阿?
谢谢!
>>jiangsheng(蒋晟.Net)
有哪里HitTest阿?
在void CMainFrame::OnContextMenu(CWnd* pWnd, CPoint point)
里面吗?

白乔 2003-01-06
  • 打赏
  • 举报
回复
你可以响应OnRButtonUp
我一直这么做的
TrackPopupMenu挺好,真的
蒋晟 2003-01-06
  • 打赏
  • 举报
回复
调用CWnd::OnContextMenu(CWnd* pWnd, CPoint point) 就是执行默认的标题栏菜单……
Hittest一下好了
zhdleo 2003-01-06
  • 打赏
  • 举报
回复
老兄,你的不同区域指的是 怎么个不同?
突击召唤师 2003-01-06
  • 打赏
  • 举报
回复
点在标题栏上,你要处理WM_SYSCOMMAND
goodsong 2003-01-06
  • 打赏
  • 举报
回复
>>abica()
>>我认为你该先判断点在什么地方了
我就是不知道怎样判断点在哪里了,
我是用MFC编程的,有没有简单可行的办法呀?
浩曦 2003-01-06
  • 打赏
  • 举报
回复
是Switch,我写错了.哈哈
浩曦 2003-01-06
  • 打赏
  • 举报
回复
我认为你该先判断点在什么地方了,然后用SWATCH对不同地方做出不同的处理,当然要准备好不同的菜单.

15,978

社区成员

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

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