Default Context Menu on Edit Control
Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=2738
Printed Date: 24 June 2025 at 4:51am Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com
Topic: Default Context Menu on Edit Control
Posted By: mwest
Subject: Default Context Menu on Edit Control
Date 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 - http://www.codeproject.com/editctrl/cmenuedit.asp
Thanks!
|
Replies:
Posted By: mwest
Date Posted: 17 August 2005 at 5:50pm
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 - 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
|
|