We recommend using Visual Studio 2017
This documentation is archived and is not being maintained.


This member function is called by the framework to copy data from one application to another.

afx_msg BOOL OnCopyData(
   CWnd* pWnd,
   COPYDATASTRUCT* pCopyDataStruct 


A pointer to a CWnd object that is sending the data.


A pointer to a COPYDATASTRUCT structure that contains the data being sent.

Returns TRUE if the receiving application successfully accepts the data. Otherwise, returns FALSE.

The data being passed must not contain pointers or other references to objects not accessible to the application receiving the data.

While the data is being copied, it must not be changed by another thread of the sending process.

The receiving application should consider the data read-only. The structure pointed to by the parameter pCopyDataStruct is valid only during the transfer of data; however, the receiving application should not free the memory associated with the structure.

If the receiving application needs access to the data after this function returns, it must copy the data received to a local buffer.


This member function is called by the framework to allow your application to handle a Windows message. The parameters passed to your function reflect the parameters received by the framework when the message was received. If you call the base-class implementation of this function, that implementation will use the parameters originally passed with the message and not the parameters you supply to the function.

Header: afxwin.h