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

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


CEdit-- How Do I Defeat the Right Mouse Button Menu?

Bruce DeGraaf -- bdegraaf@datx.com
Wednesday, January 15, 1997


Environment: VC++ 4.2b, NT 4.0

If you right-mouse click on a CEdit, a menu for Cut, Paste, etc appears.   
I have a derived (from CEdit) class.
HOW DO I DEFEAT THIS MENU?
I have tried in both the derived class and the calling (dialog derived)   
class:
1. OnRButtonDblclk, OnRButtonDown, and OnRButtonUp
I tried just not passing on the control by commenting out the default   
code.
2. WM_RBUTTONDBLCLK, WM_RBUTTONDOWN, WM_RBUTTONUP
I tried simply ignoring these messages in the WindowProc
I've seen a reference to this menu before (in some list of tricks).
Thanks!



Greg D. Tighe -- gdt@eng.aisinc.com
Friday, January 17, 1997

[Mini-digest: 5 responses]

Under Windows 95, if I add a CEdit control member variable to a 
dialog class and then hand edit the dialog class' header file and 
change the CEdit member variable to be of class CMyEdit, I can then 
add an OnRButtonUp() handler to CMyEdit (using ClassWizard.)

Within CMyEdit::OnRButtonUp(), if I then comment out the call to 
CEdit::OnRButtonUp() this will disable the right mouse button menu.

> Environment: VC++ 4.2b, NT 4.0
> 
> If you right-mouse click on a CEdit, a menu for Cut, Paste, etc appears.   
> I have a derived (from CEdit) class.
> HOW DO I DEFEAT THIS MENU?

	-Greg Tighe
	Applied Intelligent Systems, Inc.
	Ann Arbor, MI
	gdt@aisinc.com
-----From: "James P. Kelleghan" 

Try using PreProcessMessage().

----------
> From: Bruce DeGraaf 
> To: 'mfc-l@netcom.com'
> Subject: CEdit-- How Do I Defeat the Right Mouse Button Menu?
> Date: Wednesday, January 15, 1997 5:39 PM
> 
> 
> Environment: VC++ 4.2b, NT 4.0
> 
> If you right-mouse click on a CEdit, a menu for Cut, Paste, etc appears. 
 
> I have a derived (from CEdit) class.
> HOW DO I DEFEAT THIS MENU?
> I have tried in both the derived class and the calling (dialog derived)  

> class:
> 1. OnRButtonDblclk, OnRButtonDown, and OnRButtonUp
> I tried just not passing on the control by commenting out the default   
> code.
> 2. WM_RBUTTONDBLCLK, WM_RBUTTONDOWN, WM_RBUTTONUP
> I tried simply ignoring these messages in the WindowProc
> I've seen a reference to this menu before (in some list of tricks).
> Thanks!
-----From: Raja Segar 

At 18:39 15/01/1997 EST, you wrote:
>
>Environment: VC++ 4.2b, NT 4.0
>
>If you right-mouse click on a CEdit, a menu for Cut, Paste, etc appears.   
>I have a derived (from CEdit) class.
>HOW DO I DEFEAT THIS MENU?
>I have tried in both the derived class and the calling (dialog derived)   
>class:
>1. OnRButtonDblclk, OnRButtonDown, and OnRButtonUp
>I tried just not passing on the control by commenting out the default   
>code.
>2. WM_RBUTTONDBLCLK, WM_RBUTTONDOWN, WM_RBUTTONUP
>I tried simply ignoring these messages in the WindowProc
>I've seen a reference to this menu before (in some list of tricks).
>Thanks!
>

Hi there ...here is how i do it

void CMyEditCtrl:OnRButtonDown(UINT nFlags, CPoint point) 
{
     // TODO: Add your message handler code here and/or call default
	
     // CEdit::OnRButtonDown (nFlags, point);
     // remark the line above and replace it with the line below
     return;    // he he he this is all that neesed to do the job;
}

Hope this solves your problem.
Bye
 (  _ \/ __)(_   )
  )   /\__ \ / /_ 
 (_)\_)(___/(____)@pc.jaring.my

-----From: SCS.007@mch.scn.de


It worked perfectly for me.

// MyEdit.h

class MyEdit : public CEdit
{
// [Code snipped]
	// Generated message map functions
protected:
	//{{AFX_MSG(MyEdit)
	afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
	//}}AFX_MSG

	DECLARE_MESSAGE_MAP()
};


// MyEdit.cpp :

BEGIN_MESSAGE_MAP(MyEdit, CEdit)
	//{{AFX_MSG_MAP(MyEdit)
	ON_WM_RBUTTONDOWN()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// MyEdit message handlers

void MyEdit::OnRButtonDown(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	TRACE("Trapped RT-ButtonDnClick\n");
}

Can you send the code you had written???

Chandru.
-----From: Roger Onslow/Newcastle/Computer Systems Australia/AU

>If you right-mouse click on a CEdit, a menu for Cut, Paste, etc appears.   

Have you tried overriding/ignoring the WM_CONTEXTMENU message (which may be 
what eidt control is responding to)

Here is docco on it from SDK:

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
The WM_CONTEXTMENU message notifies a window that the user clicked the right 
mouse button (right clicked) in the window.
hwnd = (HWND) wParam;  
xPos = LOWORD(lParam); 
yPos = HIWORD(lParam); 
 
Parameters
hwnd
Handle to the window in which the user right clicked the mouse. This can be a 
child window of the window receiving the message. For more information about 
processing this message, see the Remarks section.
xPos 
Horizontal position of the cursor, in screen coordinates, at the time of the 
mouse click.
yPos
Vertical position of the cursor, in screen coordinates, at the time of the 
mouse click.
 
Return Values
No return value.
Remarks
A window can process this message by displaying a shortcut menu using the 
TrackPopupMenu or TrackPopupMenuEx function.
If a window does not display a shortcut menu it should pass this message to the 
DefWindowProc function. If a window is a child window, DefWindowProc sends the 
message to the parent. Otherwise, DefWindowProc displays a default shortcut 
menu if the specified position is in the window's caption.
DefWindowProc generates the WM_CONTEXTMENU message when it processes the 
WM_RBUTTONUP or WM_NCRBUTTONUP message.
See Also
DefWindowProc, TrackPopupMenu, TrackPopupMenuEx, WM_NCRBUTTONUP, WM_RBUTTONUP 
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Hope this helps

============================================================
   Roger Onslow
 Software Development Manager - Quisine Division
  Computer Systems Australia
------------------------------------------------------------
Ph:   +61 49 675266
Fax:   +61 49 675554
Personal  mailto:Roger_Onslow@compsys.com.au
Quisine info mailto:Quisine@compsys.com.au
Visit us at  http://www.compsys.com.au/Quisine.html
============================================================
  Quisine - Designing for the Future
============================================================




Paul Martinsen -- pmartinsen@hort.cri.nz
Monday, January 20, 1997

[Mini-digest: 2 responses]

> 
> Environment: VC++ 4.2b, NT 4.0
> 
> If you right-mouse click on a CEdit, a menu for Cut, Paste, etc appears.   
> I have a derived (from CEdit) class.
> HOW DO I DEFEAT THIS MENU?
I haven't tried this, but there is a WM_CONTEXTMENU message now. 
Maybe trapping this one might help?
Paul.
Paul Martinsen.
---------------------------------------------------------------
PhD Student.    p.martinsen@auckland.ac.nz
Deparment of Electrical and Electronic Engineering
University of Auckland.               Hort+Research
Private Bag                           Ruakura Research Centre
Auckland                              Hamilton.
New Zealand                           New Zealand.
---------------------------------------------------------------
-----From: pjn@indigo.ie (pjn)

On Wed, 15 Jan 97 18:39:00 EST, you wrote:

>
>Environment: VC++ 4.2b, NT 4.0
>
>If you right-mouse click on a CEdit, a menu for Cut, Paste, etc appears.=
  =20
>I have a derived (from CEdit) class.
>HOW DO I DEFEAT THIS MENU?
>I have tried in both the derived class and the calling (dialog derived) =
 =20
>class:
>1. OnRButtonDblclk, OnRButtonDown, and OnRButtonUp
>I tried just not passing on the control by commenting out the default  =20
>code.
>2. WM_RBUTTONDBLCLK, WM_RBUTTONDOWN, WM_RBUTTONUP
>I tried simply ignoring these messages in the WindowProc
>I've seen a reference to this menu before (in some list of tricks).
>Thanks!
>

Handle WM_CONTEXTMENU
                             '''	  =20
                             @ @
+=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
ooO-(_)-Ooo=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+
|                                           PJ Naughter              |
|                                                                    |
| Software Developer                   Email: pjn@indigo.ie          |
| Softech Telecom                      Tel:   +353-1-2958384         |
|                                      Fax:   +353-1-2956290         |
| Author of DTime - A Collection       URL:   http://indigo.ie/~pjn  |
| of Date & Time classes for MFC       Mail:  Cahore,                |
|            And                              Ballygarret,           |
| Notpad, the best Notepad clone              Gorey                  |
| for Windows 95 and NT 4                     Co. Wexford            |
|                                             Ireland                |
|                                                                    |
+=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+



Bryan Schilling -- bchili@execpc.com
Tuesday, January 21, 1997

Bruce DeGraaf wrote:
> 
> Environment: VC++ 4.2b, NT 4.0
> 
> If you right-mouse click on a CEdit, a menu for Cut, Paste, etc appears.
> I have a derived (from CEdit) class.
> HOW DO I DEFEAT THIS MENU?
> I have tried in both the derived class and the calling (dialog derived)
> class:
> 1. OnRButtonDblclk, OnRButtonDown, and OnRButtonUp
> I tried just not passing on the control by commenting out the default
> code.
> 2. WM_RBUTTONDBLCLK, WM_RBUTTONDOWN, WM_RBUTTONUP
> I tried simply ignoring these messages in the WindowProc
> I've seen a reference to this menu before (in some list of tricks).
> Thanks!


Override OnContextMenu




| Вернуться в корень Архива |