Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - Default Context Menu on Edit Control
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Default Context Menu on Edit Control

 Post Reply Post Reply
Author
Message
mwest View Drop Down
Newbie
Newbie
Avatar

Joined: 13 June 2005
Location: United States
Status: Offline
Points: 14
Post Options Post Options   Thanks (0) Thanks(0)   Quote mwest Quote  Post ReplyReply Direct Link To This Post Topic: Default Context Menu on Edit Control
    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!
Back to Top
mwest View Drop Down
Newbie
Newbie
Avatar

Joined: 13 June 2005
Location: United States
Status: Offline
Points: 14
Post Options Post Options   Thanks (0) Thanks(0)   Quote mwest Quote  Post ReplyReply Direct Link To This Post 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

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
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.172 seconds.