WM_COPY,WM_PASTER override in CEdit



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()
{
}


.



Relevant Pages

  • Re: WM_COPY,WM_PASTER override in CEdit
    ... The problem has to do with the overrides to WM_COPY and WM_PASTE in my ... I have 2 edit controls in a dialog based app. ... afx_msg void OnPaste; ...
    (microsoft.public.vc.mfc)
  • RE: Ribbon primarily designed to drive sales rather than improve usabi
    ... using a new app or OS you may ... regularly with Excel 2003. ... looking for, can you believe it, edit, replace!!! ... I see there is a tool to customize the ribbon which cost $30 at think ...
    (microsoft.public.office.misc)
  • Re: Some Problem With FileSystemWatcher openNETCF
    ... void File_Monitor_Deleted(object sender, FileSystemEventArgs ... I want after i start my app and browse for example to the My Documents ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: MT-Newswatcher feature request
    ... then swipe over it. ... If a newsreader treats a click on an ... you can't edit or copy a link the same way you'd ... inconsistent with how you'd edit or select text anywhere else in the app. ...
    (comp.sys.mac.apps)
  • Re: weird delays when editing code for CF project with VS 2003
    ... network location of our assembly key file. ... >> I'm developing a CF app with VS 2003. ... >> to allow smooth editing? ... It is so bad that I can edit the code faster in ...
    (microsoft.public.dotnet.framework.compactframework)