Print Page | Close Window

Override ReportControl copy/paste functions?

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Report Control
Forum Description: Topics Related to Codejock Report Control
URL: http://forum.codejock.com/forum_posts.asp?TID=15295
Printed Date: 07 May 2025 at 4:10pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Override ReportControl copy/paste functions?
Posted By: unknow
Subject: Override ReportControl copy/paste functions?
Date Posted: 04 October 2009 at 1:45pm
Hi. I am using a CXTPReportView which has a built-in CXTPReportControl.
 
The application I generated is automatically handling the cut/copy/paste functions and it cause me trouble.
 
For example, I would like to manage my own copy/cut text data format and use XML, which means I need to intercept the cut/copy/paste messages.
 
I would prefer to handle these message from the CXTPReportView rather and derivate the ReportControl class.
 
Any hint ?
 
Thanks!!



Replies:
Posted By: mdoubson
Date Posted: 04 October 2009 at 3:15pm

ReportPaneViewView.h

class CReportPaneViewView : public CXTPReportView

protected:

afx_msg void OnEditCut();

afx_msg void OnEditCopy();

afx_msg void OnEditPaste();

afx_msg void OnUpdateEditPaste(CCmdUI* pCmdUI);

afx_msg void OnUpdateEditCopy(CCmdUI* pCmdUI);

afx_msg void OnUpdateEditCut(CCmdUI* pCmdUI);

ReportPaneViewView.cpp

BEGIN_MESSAGE_MAP(CReportPaneViewView, CXTPReportView)

//{{AFX_MSG_MAP(CReportPaneViewView)

 ON_COMMAND(ID_EDIT_CUT, OnEditCut)

ON_COMMAND(ID_EDIT_COPY, OnEditCopy)

ON_COMMAND(ID_EDIT_PASTE, OnEditPaste)

//}}AFX_MSG_MAP

END_MESSAGE_MAP()

void CReportPaneViewView::OnEditCut() { AfxMessageBox(_T("OnEditCut")); } .......



-------------
Mark Doubson, Ph.D.


Posted By: unknow
Date Posted: 04 October 2009 at 5:50pm
Thankx! It was the easiest way to do it  I didn't tried it as I thought the ReportControl would prevent from the CView messages;
 
On the same way, I would also need to intercept items dragged into the ReportControl in order to change some data on the fly;
 
Which message handled / function should I add and how to get the handles of dropped Report items ?
 
Thankx!


Posted By: mdoubson
Date Posted: 05 October 2009 at 9:04am
You can use your own class derived from CXTPReportControl and overwrite functions

virtual void OnBeginDrag(CPoint point);
virtual DROPEFFECT OnDragOver(COleDataObject* pDataObject, DWORD dwKeyState, CPoint point, int nState);
virtual BOOL OnDrop(COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point);
 
you can also try the previous post way...


-------------
Mark Doubson, Ph.D.


Posted By: unknow
Date Posted: 07 October 2009 at 12:34pm
Originally posted by mdoubson mdoubson wrote:

you can also try the previous post way...
You mean by handling messages from the control (like NM_BEGINDRAG) from the ReportView ?


Posted By: mdoubson
Date Posted: 07 October 2009 at 12:36pm
If you wish

-------------
Mark Doubson, Ph.D.


Posted By: unknow
Date Posted: 07 October 2009 at 12:50pm
ok, I forgot to ask: how to retrieve pointer to the dropped items from the handle message ?


Posted By: mdoubson
Date Posted: 08 October 2009 at 12:09pm
I am sure you can do this research yourself

-------------
Mark Doubson, Ph.D.


Posted By: unknow
Date Posted: 08 October 2009 at 12:38pm
Yep, sorry, that was an easy one, here's the answer for those who would be interested:
 
Add this handle in the ReportView (dont' forget include file declaration):
 ON_NOTIFY(XTP_NM_REPORT_DROP, XTP_ID_REPORT_CONTROL, OnReportDrop)
 
Then this code:
void CReportSampleView::OnReportDrop(NMHDR * pNotifyStruct, LRESULT * /*result*/)
{
      XTP_NM_REPORTDRAGDROP* pItemNotify = (XTP_NM_REPORTDRAGDROP*)pNotifyStruct;
      ASSERT(pItemNotify->pRecords);
 
      // in this example, we access to a derivated CXTPReportRecord class with a GetTitle function 
      CString strTitle;
 
      // handle each dropped record one after another
       for (int i=0; i<pItemNotify->pRecords->GetCount(); i++)
       {
            CMyDerivatedRecord* pRecord = ((CMyDerivatedRecord*)pItemNotify->pRecords->GetAt(i));
 
            strTitle = (pRecord->GetAt(i))->GetTitle();
 
            // do something, like for example change Title to avoid duplicates ;-)
            ChangeTitleFunction(strTitle);
 
            ((CXTPReportRecordItemText*)pRecord->GetItem(IDX_TITLE))->SetValue(strTitle);
       }
}
This example should work for any other DragnDrop notification messages;


Posted By: mdoubson
Date Posted: 08 October 2009 at 12:47pm
Good

-------------
Mark Doubson, Ph.D.


Posted By: mdoubson
Date Posted: 08 October 2009 at 6:57pm

BOOL CXTPReportPaintManager::m_bForceShowDropMarker; // TRUE if Force Show Drop Marker

//used to support external (OLE) drag & drop handler and take care of drop marker line drawing and auto-scrolling



-------------
Mark Doubson, Ph.D.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net