WM_COPY,WM_PASTER override in CEdit
- From: "mike" <nospamplease.com>
- Date: Thu, 13 Jul 2006 11:26:47 -0400
I want to modify data that is copied from and to my application through the
clipboard. Everthing works perfectly in debug mode but the app crashes in
release version. The debugger doesn't display any exception errors or access
errors in debug mode.
The problem has to do with the overrides to WM_COPY and WM_PASTE in my
CEdit derived class.
These messages do not display through MFC's message map so I added them
manually.
I have 2 edit controls in a dialog based app.
CCustEdit m_Edit1;
CCustEdit m_Edit2;
In OnInitDialog() I subclass each edit
m_Edit1.SubclassDlgItem(IDC_EDIT1,this);
m_Edit2.SubclassDlgItem(IDC_EDIT2,this);
The edits are not included in the DoDataExchange macro
In the release compiled version:
When the app runs, I enter data into edit1, highlight the data, and right
click on the edit and click copy. The OnCopy override has no code at this
time so the clipboard is not involved..
When my mouse simply moves into the edit2 space, the app crashes. I don't
click in the box or anything, just the mouse move.
Spy shows this message after the WM_COPY on edit 1
000B06EC R WM_CONTEXTMENU
000B06EC P message 0x0118 (UnKnown) wParam 0000FFFF lParam BF8C3DCA
000B06EC P message 0x0118 (UnKnown) wParam 0000FFFF lParam BF8C3DCA
000B06EC S.WM_GETDLGCODE
000B06EC R WM_GETDLGCODE
fuDlgCode:DLGC_WANTARROWS|DLGC_HASSETSEL|DLGC_WANTCHARS
I've created a clean Dialog app with a simple derived CEdit class with
overrides to the above commmands. Below is the derived class. Are these
overrides illegal?
Is there something I'm not doing?
class CCustEdit : public CEdit
{
// Construction
public:
CCustEdit();
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CCustEdit)
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CCustEdit();
// Generated message map functions
protected:
//{{AFX_MSG(CCustEdit)
afx_msg void OnCopy();
afx_msg void OnPaste();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
// CCustEdit
CCustEdit::CCustEdit()
{
}
CCustEdit::~CCustEdit()
{
}
BEGIN_MESSAGE_MAP(CCustEdit, CEdit)
//{{AFX_MSG_MAP(CCustEdit)
ON_MESSAGE(WM_COPY, OnCopy)
ON_MESSAGE(WM_PASTE, OnPaste)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
// Function name : CCustEdit::OnCopy
// Description :
// Return type : void
//////////////////////////////////////////////////////////////////////
void CCustEdit::OnCopy()
{
}
//////////////////////////////////////////////////////////////////////
// Function name : CCustEdit::OnPaste
// Description :
// Return type : void
//////////////////////////////////////////////////////////////////////
void CCustEdit::OnPaste()
{
}
.
- Follow-Ups:
- Re: WM_COPY,WM_PASTER override in CEdit
- From: mike
- Re: WM_COPY,WM_PASTER override in CEdit
- Prev by Date: Re: Realtime validation feedback
- Next by Date: Re: Numeric spin control,
- Previous by thread: Re: How the application knows whether the machine is Laptop or Desktop
- Next by thread: Re: WM_COPY,WM_PASTER override in CEdit
- Index(es):
Relevant Pages
|