Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Report Control
  New Posts New Posts RSS Feed - Override ReportControl copy/paste functions?
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Override ReportControl copy/paste functions?

 Post Reply Post Reply
Author
Message
unknow View Drop Down
Groupie
Groupie
Avatar

Joined: 14 January 2009
Location: Belgium
Status: Offline
Points: 62
Post Options Post Options   Thanks (0) Thanks(0)   Quote unknow Quote  Post ReplyReply Direct Link To This Post Topic: Override ReportControl copy/paste functions?
    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!!
Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post 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")); } .......

Back to Top
unknow View Drop Down
Groupie
Groupie
Avatar

Joined: 14 January 2009
Location: Belgium
Status: Offline
Points: 62
Post Options Post Options   Thanks (0) Thanks(0)   Quote unknow Quote  Post ReplyReply Direct Link To This Post 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!
Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post 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...
Back to Top
unknow View Drop Down
Groupie
Groupie
Avatar

Joined: 14 January 2009
Location: Belgium
Status: Offline
Points: 62
Post Options Post Options   Thanks (0) Thanks(0)   Quote unknow Quote  Post ReplyReply Direct Link To This Post 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 ?
Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post Posted: 07 October 2009 at 12:36pm
If you wish
Back to Top
unknow View Drop Down
Groupie
Groupie
Avatar

Joined: 14 January 2009
Location: Belgium
Status: Offline
Points: 62
Post Options Post Options   Thanks (0) Thanks(0)   Quote unknow Quote  Post ReplyReply Direct Link To This Post Posted: 07 October 2009 at 12:50pm
ok, I forgot to ask: how to retrieve pointer to the dropped items from the handle message ?
Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post Posted: 08 October 2009 at 12:09pm
I am sure you can do this research yourself
Back to Top
unknow View Drop Down
Groupie
Groupie
Avatar

Joined: 14 January 2009
Location: Belgium
Status: Offline
Points: 62
Post Options Post Options   Thanks (0) Thanks(0)   Quote unknow Quote  Post ReplyReply Direct Link To This Post 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;
Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post Posted: 08 October 2009 at 12:47pm
Good
Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post 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

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.172 seconds.