Board index » Visual Studio » Drag and Drop Problem

Drag and Drop Problem

Visual Studio113
Hi Everyone,



I have a drag and drop problem. I have an MDI application. The child frame

has two docking pannels and a view. One of the docking pannels is a

CListCtrl. I allow users to drag and drop listbox items from one view to

another. That part works fine. Where I am having a problem is when the list

box of the view being dragged to is covered by another window.

So what I did was created a COleDropTarget for the Child frame and all it

did was when the OnDragOver gets called I call BringWindowToTop(m_hWnd) to

bring the window that the mouse is on to the Top and this part works fine

too.



Now on the view part of the MDI frames I have CRichEditCtrls and since the

rich edit controls do their own drag and drop my child frame's

COleDropTarget doesn't get the drag messages. So the user will have to drag

the mouse to another part of the view where there is no CRichEditCtrl in

order to bring up the view.

Is there a way to get around this problem and keep the drag and drop feature

of the Rich edit control without having to redo the entire Drag and drop for

the CRichEditCtrl.



If I could override the drag and drop routines of the CRichEditCtrl so that

I can call BringWindowToTop and then call the base class routine to let it

handle it's drag and drop, it would solve the problem!?



AliR.


-
 

Re:Drag and Drop Problem

Hi Ali,



Quote
So the user will have to drag the mouse to another part

of the view where there is no CRichEditCtrl in order to

bring up the view.



Do you mean the view will not be brought to the foreground when you drag

and drop the file to it?



If so, I think you may try to handle the EN_DROPFILES message of the target

RichEdit control, put your BringWindowToTop call in its handler function

and then call the base class routine in it...





Thanks!



Best regards,



Gary Chang

Microsoft Community Support

--------------------

Get Secure! ¡§C www.microsoft.com/security

Register to Access MSDN Managed Newsgroups!

http://support.microsoft.com/default.aspx?scid" rel="nofollow" target="_blank">support.microsoft.com/default.aspx=/servicedesks/msdn/nospam.asp

&SD=msdn



This posting is provided "AS IS" with no warranties, and confers no rights.



-

Re:Drag and Drop Problem

The reason I hadn't tried that was because the doc said that EN_DROPFILES

gets called after the user releases the mouse button. I want to bring the

view to the foreground when the mouse is dragged over the rich edit control

(for example where OnDragEnter or OnDragOver would get called.)



Anyway I tired to catch the message in my CRichEditCtrl derived class using

message reflection but it never got called. I am setting the ENM_DROPFILES

event flag. But it never gets called.



Either way unless the sdk docs are incorrect EN_DROPFILES isn't really going

to help me.



AliR.



""Gary Chang[MSFT]"" <v-garych@online.microsoft.com>wrote in message

Quote
Hi Ali,



>So the user will have to drag the mouse to another part

>of the view where there is no CRichEditCtrl in order to

>bring up the view.



Do you mean the view will not be brought to the foreground when you drag

and drop the file to it?



If so, I think you may try to handle the EN_DROPFILES message of the

target

RichEdit control, put your BringWindowToTop call in its handler function

and then call the base class routine in it...





Thanks!



Best regards,



Gary Chang

Microsoft Community Support

--------------------

Get Secure! ¡§C www.microsoft.com/security

Register to Access MSDN Managed Newsgroups!



http://support.microsoft.com/default.aspx?scid" rel="nofollow" target="_blank">support.microsoft.com/default.aspx=/servicedesks/msdn/nospam.asp

&SD=msdn



This posting is provided "AS IS" with no warranties, and confers no

rights.







-

Re:Drag and Drop Problem

Hi Ali,



Quote
Anyway I tired to catch the message in my CRichEditCtrl derived class

using message reflection but it never got called. I am setting the

ENM_DROPFILES event flag. But it never gets called.



I am afraid I miss it, the CRichEditCtrl class is not a genuine MFC class,

so the usual MFC approach may not work to it.



I think you may need to implement the IRichEditOleCallback OLE interfaces

to workaround this, and call SendMessage with EM_SETOLECALLBACK to pass a

pointer to your interface (in PreSubclassWindow or OnCreate function).,

then you can customize the IRichEditOleCallback::QueryAcceptData /

GetDragDropEffect call to respond the drag and drop event . I suggest you

take a look at afxrich.h, there has some useful sample code.



Please also refer to the following MSDN KB article for how these interfaces

are implemented in RichEdit and other implementation details :



SAMPLE: RichEdit.exe - Inserts OLE Object Capabilities

http://support.microsoft.com/?id" rel="nofollow" target="_blank">support.microsoft.com/=141549





Thanks!



Best regards,



Gary Chang

Microsoft Community Support

--------------------

Get Secure! ¡§C www.microsoft.com/security

Register to Access MSDN Managed Newsgroups!

http://support.microsoft.com/default.aspx?scid" rel="nofollow" target="_blank">support.microsoft.com/default.aspx=/servicedesks/msdn/nospam.asp

&SD=msdn



This posting is provided "AS IS" with no warranties, and confers no rights.



-

Re:Drag and Drop Problem

Thanks Gary. I'll give it try. It sound like the way to go.



AliR.



""Gary Chang[MSFT]"" <v-garych@online.microsoft.com>wrote in message

Quote
Hi Ali,



>Anyway I tired to catch the message in my CRichEditCtrl derived class

>using message reflection but it never got called. I am setting the

>ENM_DROPFILES event flag. But it never gets called.



I am afraid I miss it, the CRichEditCtrl class is not a genuine MFC class,

so the usual MFC approach may not work to it.



I think you may need to implement the IRichEditOleCallback OLE interfaces

to workaround this, and call SendMessage with EM_SETOLECALLBACK to pass a

pointer to your interface (in PreSubclassWindow or OnCreate function).,

then you can customize the IRichEditOleCallback::QueryAcceptData /

GetDragDropEffect call to respond the drag and drop event . I suggest you

take a look at afxrich.h, there has some useful sample code.



Please also refer to the following MSDN KB article for how these

interfaces

are implemented in RichEdit and other implementation details :



SAMPLE: RichEdit.exe - Inserts OLE Object Capabilities

http://support.microsoft.com/?id" rel="nofollow" target="_blank">support.microsoft.com/=141549





Thanks!



Best regards,



Gary Chang

Microsoft Community Support

--------------------

Get Secure! ¡§C www.microsoft.com/security

Register to Access MSDN Managed Newsgroups!



http://support.microsoft.com/default.aspx?scid" rel="nofollow" target="_blank">support.microsoft.com/default.aspx=/servicedesks/msdn/nospam.asp

&SD=msdn



This posting is provided "AS IS" with no warranties, and confers no

rights.







-