OnRButtonDown OnContextMenu到底有什么区别

本文通过实例解析了在主框架与子框架之间的事件响应机制,包括如何在不同层级上响应鼠标右键点击事件,以及事件处理函数的调用顺序。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

 拿个例子来说把

假如你有一个主框架a,并在主框架中有个子框架b

也就是a是b的父类

 

那我在a中响应OnContextMenu,在b中响应OnRButtonDown

 

那么,我在a中鼠标右击,那只调用OnContextMenu

 

在b中,我会调用OnRButtonDown,OnContextMenu并且有顺序性!

#pragma once #include "UI/Widget/FileBrowserPanel.h" #include "UI/Dialog/ZipDrFilesDlg.h" #include "UI/Widget/HistogramView.h" class MyListBox: public CBCGPListBox { DECLARE_DYNAMIC(MyListBox) public: CToolTipCtrl mToolTip; protected: virtual void OnLButtonDown(UINT nFlags, CPoint point); }; class FileHistoryToolBar : public CBCGPToolBar { virtual void OnUpdateCmdUI(CFrameWnd* /*pTarget*/, BOOL bDisableIfNoHndler) { CBCGPToolBar::OnUpdateCmdUI ((CFrameWnd*) GetOwner (), bDisableIfNoHndler); } virtual BOOL AllowShowOnList() const { return FALSE; } }; class FileBrowserWnd; class FileGridCtrl : public CBCGPGridCtrl { public: FileGridCtrl(); virtual ~FileGridCtrl(); void SetOwner(FileBrowserWnd* pOwner); void OnDbFileSelected(const TFileRecordList& records); void DeleteSelectFiles(); protected: afx_msg void OnOpenFile(); afx_msg void OnOpenFoler(); afx_msg void OnRemoveFile(); afx_msg void OnSaveAsFile(); afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); afx_msg void OnLButtonDown(UINT nFlags, CPoint point); afx_msg void OnRButtonDown(UINT nFlags, CPoint point); afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point); DECLARE_MESSAGE_MAP() private: TFileRecordList mFileRecordList; FileBrowserWnd* mpOwner; ZipDrFilesDlg* mpZipDrFilesDlg; }; class FileBrowserWnd : public CBCGPDockingControlBar { public: FileBrowserWnd(); virtual ~FileBrowserWnd(); HistogramView& GetHistogramView(); void OnImageDataDirty(ImageBase& image); void RefreshFiles(); void DeleteSelectFiles(); protected: afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); afx_msg void OnDestroy(); afx_msg void OnSize(UINT nType, int cx, int cy); afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); afx_msg void OnPaint(); afx_msg void OnMouseMove(UINT nFlags, CPoint point); afx_msg void OnRefreshFiles(); afx_msg void OnDeleteSelFiles(); DECLARE_MESSAGE_MAP() private: FileHistoryToolBar mToolBar; FileGridCtrl mFileGrid; FileBrowserPanel mFileFilter; int mFileFilterHeight; private: CBCGPTabWnd mTabPanel; HistogramView mHistogramView; //CBCGPListBox mLogList; MyListBox mLogList; CFont mFontList; CToolTipCtrl mToolTip; private: void OnEventCallback(const std::string& event); void OnSysErCallback(const std::string& event); void OnSysLgCallback(const std::string& event); void WriteLog(CString date, CString str); };
06-17
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值