Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ole Drag'n'Drop in CMDIFrameWnd (and other not CView derived objects)

Status
Not open for further replies.

burgdavid

Programmer
Jun 22, 2000
70
DE
Hello,<br><br>(Nice to see that tek-tips is up again !)<br><br>I've got troubles with Ole drag'n'drop. I can not make it work in not CView-derived classes. I thought I have found a (logical) solution, but (unfortunately) it obviously doesn't work so I will explain this in detail.<br><br>I have succefully implemented Ole drag'n'drop in my<br>child windows of my MDI application, by<br>adding the following members and methods to the view<br>classes of my MDI childs :<br><br><br>#include &lt;afxole.h&gt; // for COleDropTargetclass myChild<br>class MyView: public CView<br>{<br>[...]<br>protected:<br>&nbsp;&nbsp;COleDropTarget m_oleDropTarget;<br>[...]<br>public:<br> virtual DROPEFFECT OnDragEnter(COleDataObject* pDataObject,<br> DWORD dwKeyState, CPoint point); virtual DROPEFFECT OnDragOver(COleDataObject* pDataObject,<br> DWORD dwKeyState, CPoint point);<br> virtual void OnDragLeave();<br>virtual BOOL OnDrop(COleDataObject* pDataObject, <br>DROPEFFECT dropEffect, CPoint point);<br> virtual DROPEFFECT OnDropEx(COleDataObject* pDataObject,<br> DROPEFFECT dropDefault, DROPEFFECT dropList, CPoint<br>point);<br>[...]<br>protected:<br>[...]<br> afx_msg void OnLButtonDown(UINT nFlags, CPoint point); // in order to start drag'n'drop<br>[...]<br>};<br><br><br>and I register the COleDropTarget in the OnCreate<br>member as follows:<br><br><br>if (!this-&gt;m_oleDropTarget.Register(this))<br>{<br> ASSERT (FALSE);<br> CString csComObjectErrorMsg; <br> csComObjectErrorMsg.LoadStrin (IDS_COM_OBJECT_ERROR); <br> AfxMessageBox(LPCSTR(csComObjectErrorMsg)); return -1;<br> }<br><br><br>But when I try this (in fact only the drop side<br>interest me) on the CMDIFrameWnd, it doesn't work<br>(drop not allowed). I have thought this was because<br>the CMDIFramWnd does not heritate from CView so it is<br>not possible to overload the member OnDragEnter,<br>OnDrop and so on. So, I write my own object derived<br>from COleDropTarget :<br><br><br><br>class CMainFrameOleDropTarget : public<br>COleDropTarget<br>{<br>public : //constructor/destructor<br> CMainFrameOleDropTarget() {}<br> virtual ~CMainFrameOleDropTarget() {}<br> //surcharge of some handler :<br> // Drop<br> virtual DROPEFFECT OnDragEnter(COleDataObject* pDataObject,<br> DWORD dwKeyState, CPoint point); virtual DROPEFFECT OnDragOver(COleDataObject* pDataObject,<br> DWORD dwKeyState, CPoint point); virtual BOOL OnDrop(COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point);<br>};<br><br><br>And make a attribute of kind CMainFrameOleDropTarget<br>in my frame windows class that I register as before in<br>the OnCreate member.<br><br>But it didn't work either (why ?!).<br><br>Notice that I want to implemented feed-back so I need this Ole-drag'n'drop and not the other (and easier) drag'n'drop with only 'OnDrag'.<br><br>Any idea or succesfull experience with not CView derived class ? Thanks,<br><br>David Burg.<br>
 
Ok, this is very dumb to reply to her own thread, but I find the error : my overloaded methods was incorrect. I have simply copy the methods I used before with my CView derived classes, and the error is that methods of COleDropTarget have an additionnal first argument CWnd *pWnd. Now I have correct this and my methods are called, the drop works, everything fine ! :)<br><br>David Burg.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top