Override ReportControl copy/paste functions? |
Post Reply |
Author | |
unknow
Groupie Joined: 14 January 2009 Location: Belgium Status: Offline Points: 62 |
Post Options
Thanks(0)
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!!
|
|
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
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) ON_COMMAND(ID_EDIT_COPY, OnEditCopy) ON_COMMAND(ID_EDIT_PASTE, OnEditPaste) //}}AFX_MSG_MAPEND_MESSAGE_MAP() void CReportPaneViewView::OnEditCut() { AfxMessageBox(_T("OnEditCut")); } ....... |
|
unknow
Groupie Joined: 14 January 2009 Location: Belgium Status: Offline Points: 62 |
Post Options
Thanks(0)
|
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!
|
|
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
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...
|
|
unknow
Groupie Joined: 14 January 2009 Location: Belgium Status: Offline Points: 62 |
Post Options
Thanks(0)
|
You mean by handling messages from the control (like NM_BEGINDRAG) from the ReportView ?
|
|
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
If you wish
|
|
unknow
Groupie Joined: 14 January 2009 Location: Belgium Status: Offline Points: 62 |
Post Options
Thanks(0)
|
ok, I forgot to ask: how to retrieve pointer to the dropped items from the handle message ?
|
|
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
I am sure you can do this research yourself
|
|
unknow
Groupie Joined: 14 January 2009 Location: Belgium Status: Offline Points: 62 |
Post Options
Thanks(0)
|
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;
|
|
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
Good
|
|
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
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 |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |