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!

Changing the cursor on drag-n-drop operation / overwrite OLE methods 1

Status
Not open for further replies.

burgdavid

Programmer
Jun 22, 2000
70
DE
I would liek to make change the cursor during drag-n-drop like the windows explorer does when you press the key ctrl, or shift, or both (respectively force copy, move and shortcut creation).<br><br>I have found the following member of Cview object interresting :<br>OnDragEnter , OnDragOver, OnDragLeave<br>They seem to be exactly what I am looking for. I try to overwrite them manually in my object derived from CListView (itself derived from CView), but they are never called (I have put breakpoints). I also puts breakpoints in the MFC source of these method of CView, but they weren't call !!<br><br>There is what I have done for drag-n-drop implementation :<br><br>Header file :<br><br>class MyClistView: public CListView<br>{<br>...<br>public:<br> virtual DROPEFFECT OnDragEnter(COleDataObject* pDataObject,<br> DWORD dwKeyState, CPoint point);<br> virtual DROPEFFECT OnDragOver(COleDataObject* pDataObject,<br> DWORD dwKeyState, CPoint point);<br> virtual void OnDragLeave();<br><br>// Generated message map functions<br>protected:<br> //{{AFX_MSG(MyClistView)<br>...<br> afx_msg void OnDropFiles(HDROP hDropInfo);<br> //}}AFX_MSG<br>}<br><br>Cpp file :<br><br>BEGIN_MESSAGE_MAP(MyClistView, CListView)<br> //{{AFX_MSG_MAP(MyClistView)<br>...<br> ON_WM_DROPFILES()<br> //}}AFX_MSG_MAP<br> END_MESSAGE_MAP()<br><br>void MyClistView::OnDropFiles(HDROP hDropInfo) <br>{<br>...<br>}<br><br>DROPEFFECT MyClistView::OnDragEnter(COleDataObject* ,<br> DWORD, CPoint)<br>{<br> ASSERT (FALSE);<br> return 0;&nbsp;&nbsp;&nbsp;// DROPEFFECT_NONE<br>}<br><br>DROPEFFECT MyClistView::OnDragOver(COleDataObject*,<br> DWORD, CPoint)<br>{<br> ASSERT (FALSE);<br> return 0;&nbsp;&nbsp;&nbsp;// DROPEFFECT_NONE<br>}<br><br>(I have simply use classwizard for this. I'm using Visual C++6, service pack 3, under Windows nt 4 sp 6)<br><br>Thanks for help,<br><br>David.
 
Dear David,<br><br>You need to add a COleDropTarget member to your MyClistView class, say you did this:<br><br>class MyClistView : public CListView<br>{<br>protected:<br>&nbsp;&nbsp;COleDropTarget _oleDropTarget;<br>};<br><br>Then in your WM_CREATE handler<br><br>_oleDropTarget.Register(this);<br><br>Hope this helps<br>-pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top