We help IT Professionals succeed at work.

Regarding Context Menu On Edit Box(Clipboard)

ajaybhalekar
ajaybhalekar asked
on
When you right click the edit box ? it displays the context menu (Clipboard ) I Want to disable this context menu how it is possible
Comment
Watch Question

CERTIFIED EXPERT

Commented:
Hi ajaybhalekar,

simply derive a new class from CEdit, i.e. CMyEdit ... use this class to
subclass the edit box control (i.e. via ClassWizard->Member Variables->Add Variable,
Category 'Control',  Variable Type 'CMyEdit').

In CMyEdit add a message handler for WM_CONTEXTMENU (i.e. via ClassWizard) and
in this message handler function do nothing.

hope that helps,

ZOPPO

Commented:
I or U can do this by over riding  the WM_RBUTTONDOWN
and don't  call parent CEdit::OnRbuttonDown(...);




Author

Commented:
Hello Both The Solutions Dont Work

When you right click the edit box ? it displays the context menu (The Cut ,Copy ,Paste Undo ) I Want to disable this
context menu how it is possible
CERTIFIED EXPERT
Commented:
My solution works ... I've tested it ... maybe you didn't subclass the control correctly ...

BTW, you can also implement PreTranslateMessage for the dialog and avoid calling
of context menu for i.e. edit box with ID IDC_EDIT1 like this (without subclassing):

BOOL CMyDlg::PreTranslateMessage(MSG* pMsg)
{
 if ( pMsg->message == WM_RBUTTONDOWN )
 {
  CWnd* pWnd = CWnd::FromHandle( (HWND)pMsg->hwnd );
  if ( pWnd->GetDlgCtrlID() == IDC_EDIT1 )
   return TRUE;
 }
 return CDialog::PreTranslateMessage(pMsg);
}

ZOPPO

Commented:
I'm sure Overriding RButtonDown will work.
I think U did some mistake there.

Create the control from  that derived class Not from CEdit.

where U r creating ?
On dialog ? Then create the Control member from Ur derived class.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.