×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

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

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

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

(OP)
Hello,

(Nice to see that tek-tips is up again !)

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.

I have succefully implemented Ole drag'n'drop in my
child windows of my MDI application, by
adding the following members and methods to the view
classes of my MDI childs :


#include <afxole.h> // for COleDropTargetclass myChild
class MyView: public CView
{
[...]
protected:
  COleDropTarget m_oleDropTarget;
[...]
public:
virtual DROPEFFECT OnDragEnter(COleDataObject* pDataObject,
DWORD dwKeyState, CPoint point); virtual DROPEFFECT OnDragOver(COleDataObject* pDataObject,
DWORD dwKeyState, CPoint point);
virtual void OnDragLeave();
virtual BOOL OnDrop(COleDataObject* pDataObject,
DROPEFFECT dropEffect, CPoint point);
virtual DROPEFFECT OnDropEx(COleDataObject* pDataObject,
DROPEFFECT dropDefault, DROPEFFECT dropList, CPoint
point);
[...]
protected:
[...]
afx_msg void OnLButtonDown(UINT nFlags, CPoint point); // in order to start drag'n'drop
[...]
};


and I register the COleDropTarget in the OnCreate
member as follows:


if (!this->m_oleDropTarget.Register(this))
{
ASSERT (FALSE);
CString csComObjectErrorMsg;
csComObjectErrorMsg.LoadStrin (IDS_COM_OBJECT_ERROR);
AfxMessageBox(LPCSTR(csComObjectErrorMsg)); return -1;
}


But when I try this (in fact only the drop side
interest me) on the CMDIFrameWnd, it doesn't work
(drop not allowed). I have thought this was because
the CMDIFramWnd does not heritate from CView so it is
not possible to overload the member OnDragEnter,
OnDrop and so on. So, I write my own object derived
from COleDropTarget :



class CMainFrameOleDropTarget : public
COleDropTarget
{
public : //constructor/destructor
CMainFrameOleDropTarget() {}
virtual ~CMainFrameOleDropTarget() {}
//surcharge of some handler :
// Drop
virtual DROPEFFECT OnDragEnter(COleDataObject* pDataObject,
DWORD dwKeyState, CPoint point); virtual DROPEFFECT OnDragOver(COleDataObject* pDataObject,
DWORD dwKeyState, CPoint point); virtual BOOL OnDrop(COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point);
};


And make a attribute of kind CMainFrameOleDropTarget
in my frame windows class that I register as before in
the OnCreate member.

But it didn't work either (why ?!).

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'.

Any idea or succesfull experience with not CView derived class ? Thanks,

David Burg.

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

(OP)
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 ! :-)

David Burg.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close