The strange case of the missing DataObject data 
Author Message
 The strange case of the missing DataObject data

Hello all,

Please, please help me. This problem has been bogging me down for about a
week now. I have searched all the right places (Microsoft Development
Library CD's and the internet using Google), but no one seems to have ever
encountered the same problem. Which is something I cannot imagine very well.

So, here it is. Got this ActiveX control built using MFC. It has no support
for drag&drop yet, but it at least will have to be able to behave as a drop
target. It is my task to implement just that. The control does not have to
do that much when it comes to being a drop target. It merely needs to
forward some information in an event, which can be handled by some VB
application (obviously having this ActiveX control on one of its forms
somewhere), so there never is any "real drop" and never any (re)drawing

Not too difficult it seems. Just implement a COleDropTarget, register it as
a drop target and correctly handle the On. methods. At the right places just
raise VB events, by calling FireEvent. Well, I actually have all this stuff

But.the data is missing. That is, the COleDataObject::GetGlobalData method
for the data object passed onto the COleDropTarget::On. methods keeps
returning a HGLOBAL set to 0. I have tracked this down to the line "SCODE sc
= m_lpDataObject->GetData()" in the COleDataObject::GetGlobalData method.
The SCODE returned here is E_UNEXPECTED. This most definitely is very
unexpected indeed.

The COleDataObject::IsDataAvailable tells me data is available. Enumerating
the supported formats always returns a FORMATETC structure, with the
cfFormat attribute set to 1 (= CF_TEXT, which is the only format I have been
testing with so far) and the tymed attribute set to HGLOBAL. All this works
as expected.

Actually, the data is only missing if my VB drop source is set to manual OLE
dragging. If I am simply dragging a piece of text from the RTF-control, set
to automatic OLE dragging, everything works just fine. The expected text is
returned with GetGlobalData.

It makes no difference if the VB drop source sets the data immediately in
the OLEStartDrag (using Data.SetData "My Trial Text", vbCFText) or postpones
this, only to set the data once it is requested for through the OLESetData

Please note that all the VB events and the MFC methods are called at the
right moment and as far as I have been able to find drag&drop examples I
appear to be doing everything correct in my drop target implementation. It
is just that the data is missing.

So, my questions.

Is this a VB bug? Or does the VB extender twist some things around? Or do I
forget something in my MFC implementation? (I have not been able to find any
info on how to create an ActiveX control with different - i.e. automatic and
manual - drag modes at all.) Has anyone encountered this problem before and
does anybody know the answer?

I am on the verge of giving up and start constructing a very, very {*filter*} and
dirty work-around. And I really hate doing so.



Rens Segaar

Fri, 22 Oct 2004 22:21:56 GMT  
 [ 1 post ] 

 Relevant Pages 

1. Strange case of the disappearing Treeview

2. STRANGE case of ERROR 5 - Illegal Function Call

3. The strange case of the disappearing controls

4. The Strange Case of the Vanishing Buttons....

5. STRANGE case of ERROR 5 - Illegal Function Call

6. A Case of Missing Method

7. Missing Data Enviroment, Data Binding references

8. Change Case (Upper/Lower/Setence/Title CASE)

9. "", multiples cases not possible ?

10. RTF format - changing case (and case only!)

11. Select Case and Case 0 To 9

12. VBScript Select Case vs VB Select Case


Powered by phpBB® Forum Software