captureing right click mouse event........
-
how to disable user from right clicking in Edit Box.and also cant copy or paste using (ctrl+c) and (ctrl+v) in visual c++ project..
-
how to disable user from right clicking in Edit Box.and also cant copy or paste using (ctrl+c) and (ctrl+v) in visual c++ project..
-
Yes, derive your own class from CEdit and handle WM_CONTEXTMENU message . For information on WM_CONTEXTMENU[^] I hope it helps..
Regards, Sandip.
-
can u plz give me a code that using WM_CONTEXTMENU to restrict right cliking in edit box
You can try something like this..
BEGIN_MESSAGE_MAP(CMyEdit, CEdit)
//{{AFX_MSG_MAP(CMyEdit)
ON_WM_CONTEXTMENU()
//}}AFX_MSG_MAP
ON_MESSAGE(WM_COPY,OnCopy)
ON_MESSAGE(WM_PASTE,OnPaste)
END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////
// CMyEdit message handlersvoid CMyEdit::OnContextMenu(CWnd* pWnd, CPoint point)
{
// TODO: Add your message handler code here
}
void CMyEdit::OnCopy(WPARAM wParam,LPARAM lParam)
{
// TODO: Add your message handler code here
}
void CMyEdit::OnPaste(WPARAM wParam,LPARAM lParam)
{
// TODO: Add your message handler code here
}And declarations..
protected:
//{{AFX_MSG(CMyEdit)
afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
//}}AFX_MSGvoid OnCopy(WPARAM wParam,LPARAM lParam) ; void OnPaste(WPARAM wParam,LPARAM lParam) ;
I hope it helps. I assume you can derive the class from CEdit and add similar handlers to your class. Also don't forget to add the control variable of type CMyEdit for the Edit Box.
Regards, Sandip.
-
You can try something like this..
BEGIN_MESSAGE_MAP(CMyEdit, CEdit)
//{{AFX_MSG_MAP(CMyEdit)
ON_WM_CONTEXTMENU()
//}}AFX_MSG_MAP
ON_MESSAGE(WM_COPY,OnCopy)
ON_MESSAGE(WM_PASTE,OnPaste)
END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////
// CMyEdit message handlersvoid CMyEdit::OnContextMenu(CWnd* pWnd, CPoint point)
{
// TODO: Add your message handler code here
}
void CMyEdit::OnCopy(WPARAM wParam,LPARAM lParam)
{
// TODO: Add your message handler code here
}
void CMyEdit::OnPaste(WPARAM wParam,LPARAM lParam)
{
// TODO: Add your message handler code here
}And declarations..
protected:
//{{AFX_MSG(CMyEdit)
afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
//}}AFX_MSGvoid OnCopy(WPARAM wParam,LPARAM lParam) ; void OnPaste(WPARAM wParam,LPARAM lParam) ;
I hope it helps. I assume you can derive the class from CEdit and add similar handlers to your class. Also don't forget to add the control variable of type CMyEdit for the Edit Box.
Regards, Sandip.
-
thanks for da reply actually i m very beginner to visual c++ so feel problem while deriving plz can u help me further that how to derive myCEdit from CEdit and override its methods etc.... thanks in advance
I will advise you to read some book on MFC. Windows Programming with MFC by Jeff Prosise is good for beginners. Now your problem. 1. Select Insert Menu -> New Class. 2. Type In your class name (CMyEdit)and select Base class as CEdit 3. Then add the handlers and their declarations from my previous posts to the class. 4. Add the member variable of type CMyEdit for Edit box. I hope this makes sense. But I suggest you to read from book as this is something very basic.
Regards, Sandip.
-
I will advise you to read some book on MFC. Windows Programming with MFC by Jeff Prosise is good for beginners. Now your problem. 1. Select Insert Menu -> New Class. 2. Type In your class name (CMyEdit)and select Base class as CEdit 3. Then add the handlers and their declarations from my previous posts to the class. 4. Add the member variable of type CMyEdit for Edit box. I hope this makes sense. But I suggest you to read from book as this is something very basic.
Regards, Sandip.
thanks for da help after deriving CMyedit class from Edit and adding handler of WM_CONTEXTMENU, WM_COPY,WM_PASTE now plz tell the code to restrict menu and copy,paste using these methods ,means what would be coding to handle menu in these methods void CMyedit::OnContextMenu(CWnd* pWnd, CPoint point) { // TODO: Add your message handler code here } void CMyedit::OnCopy(WPARAM wParam,LPARAM lParam) { // TODO: Add your message handler code here } void CMyedit::OnPaste(WPARAM wParam,LPARAM lParam) { // TODO: Add your message handler code here }
-
thanks for da help after deriving CMyedit class from Edit and adding handler of WM_CONTEXTMENU, WM_COPY,WM_PASTE now plz tell the code to restrict menu and copy,paste using these methods ,means what would be coding to handle menu in these methods void CMyedit::OnContextMenu(CWnd* pWnd, CPoint point) { // TODO: Add your message handler code here } void CMyedit::OnCopy(WPARAM wParam,LPARAM lParam) { // TODO: Add your message handler code here } void CMyedit::OnPaste(WPARAM wParam,LPARAM lParam) { // TODO: Add your message handler code here }
Blank implementation will prevent the Menu as well as copy and paste. You must have not added the member variable of type CMyEdit to your dialog in which you have your Edit Box.. You need to associate your class with the EditBox by adding a member variable and respective call to DDX_Control in the functio DoDataExchange().. No need to edit this manually you can use wizard to add the variable. Only thing wizard will not do is to include header file MyEdit.h which you need to include manually. I hope it is clear.
Regards, Sandip.