15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


How to get a handle to the CEdit Popup Menu

Mark Johnson -- MJohnson@ixc-comm.net
Wednesday, April 02, 1997

Environment: VC++ 4.2-flat, NT 4.0

I can't seem to find where the Popup Menu for the CEdit control
is created.  

What I want to do is insert two more menu items into that popup menu.

Any suggestions, Mark.



David Little -- dlittle@equinoxcorp.com
Thursday, April 03, 1997

Add a handler to the WM_CONTEXTMENU message and do it there.....

----------
From: 	Mark Johnson[SMTP:MJohnson@ixc-comm.net]
Sent: 	Wednesday, April 02, 1997 8:21 AM
To: 	'mfc-l@netcom.com'
Subject: 	How to get a handle to the CEdit Popup Menu

Environment: VC++ 4.2-flat, NT 4.0

I can't seem to find where the Popup Menu for the CEdit control
is created.  

What I want to do is insert two more menu items into that popup menu.

Any suggestions, Mark.



ktm@ormec.com
Thursday, April 03, 1997

On mfc-l, Mark Johnson (mjohnson@ixc-comm.net) wrote:
> Environment: VC++ 4.2-flat, NT 4.0
You should upgrade to VC++ 4.2b or 5.0. 4.2-flat was only valid for beta
versions of some operating system components, and isn't guaranteed to be
correct anymore.

> I can't seem to find where the Popup Menu for the CEdit control
> is created.

It's done by the default window procedure. (There is no 
CEdit::OnContextMenu, and CWnd::OnContextMenu just calls Default()).

> What I want to do is insert two more menu items into that popup menu.

I don't think you can do that exactly. What you can do is show a context
menu created completely by you. You can set the first few items in the
menu to the defaults (e.g. Undo/Cut/Copy/Paste/Delete/Select All) and
put your own menu items at the end.

To make your own menu and show it in the CEdit:
1) Derive a class from CEdit, and add a handler for WM_CONTEXTMENU

2) In the WM_CONTEXTMENU handler, load your menu, and call 
   TrackPopupMenu based on the point passed to you. There's an
   example of writing this handler in the "Adding Windows 95 
   Functionality" section of the VC++ Tutorials.

3) In your dialog or FormView, subclass the edit control with an 
   instance of your own control. Online help for SubclassDlgItem 
   will get you started.
   
  Katy
-- 
Katy Mulvey                    <mailto:ktm@ormec.com>
Software Development Engineer
ORMEC Systems



Kostya Sebov -- sebov@is.kiev.ua
Friday, April 04, 1997

I think, WM_INITMENUPOPUP handler might be a better idea because 
what the original poster wants is to *extend* the default behavior 
not to provide the alternative one.
	Kostya Sebov. 
----------------------------------------------------------------------------
Tel: +(38 044) 266-6387 /work/,   +(38 044) 513-2591 /home/
mailto:sebov@is.kiev.ua
---------------------------------------------------------------------------
MCPS, Leading programmer 
Intelligent Systems (Boston-Kiev)
voice/fax: +(38 044)266-6195
mailto:company@is.kiev.ua
http://www.i-rip.com


-----Original Message-----
From:	David Little [SMTP:dlittle@equinoxcorp.com]
Sent:	Thursday, April 03, 1997 17:18
To:	'mfc-l@netcom.com'
Subject:	RE: How to get a handle to the CEdit Popup Menu

Add a handler to the WM_CONTEXTMENU message and do it there.....

----------
From: 	Mark Johnson[SMTP:MJohnson@ixc-comm.net]
Sent: 	Wednesday, April 02, 1997 8:21 AM
To: 	'mfc-l@netcom.com'
Subject: 	How to get a handle to the CEdit Popup Menu

Environment: VC++ 4.2-flat, NT 4.0

I can't seem to find where the Popup Menu for the CEdit control
is created.  

What I want to do is insert two more menu items into that popup menu.

Any suggestions, Mark.







Become an MFC-L member | Вернуться в корень Архива |