Default Context Menu on Edit Control |
Post Reply |
Author | |
mwest
Newbie Joined: 13 June 2005 Location: United States Status: Offline Points: 14 |
Post Options
Thanks(0)
Posted: 17 August 2005 at 12:21pm |
I have a CXTPControlEditCtrl in a toolbar that displays a
default context menu when I right click on it. I would like to
provide a custom context menu, but I am unsure how to do it. If
CXTPControlEditCtrl was derived from CEdit instead of
CXTPControl I would know what do do. Can anyone help me?
Here is an article on how to do it normally: http://www.codeproject.com/editctrl/cmenuedit.asp Thanks! |
|
mwest
Newbie Joined: 13 June 2005 Location: United States Status: Offline Points: 14 |
Post Options
Thanks(0)
|
My last post is absurd. I have been looking at code for too long.
CXTPControlEditCtrl is derived from CEdit. Sorry about that. I did come up with a way to get the context menu instead of the menu pop up: 1. Make a custom derived CXTPControlEdit and the Edit Control class that CreateEditControl() will return (this class is derived from CXTPControlEditCtrl). See the User Guide: Chapter 4 - How to Add Custom Command Bar Controls to Your Application. 2. The edit control class (the one derived from CXTPControlEditCtrl) should override the OnRButtonDown() handler (ON_WM_RBUTTONDOWN()). 3. Then just call the CXTPEdit::OnRButtonDown() instead of the CXTPControlEditCtrl::OnRButtonDown (CXTPControlEditCtrl's method creates the menu that has Cut, Paste, etc... Take a look at the source for it.) 4. Override the OnContextMenu() handler (ON_WM_CONTEXTMENU()) in accordance with however you want your context menu to look. See http://www.codeproject.com/editctrl/cmenuedit.asp 5. Run it and you will see your context menu. Here are a few keywords for people searching for this solution: copy, paste, cut, toolbar, context menu, edit, right click, ShowContextMenu, CXTPEdit, ID_EDIT_CUT, ID_EDIT_COPY, ID_EDIT_PASTE, default context menu Edited by mwest |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |