implementing IDataObject

implementing IDataObject

Post by Patrick Barr » Tue, 27 Jun 2000 04:00:00



I want my namespace extension to support copy&paste and drag&drop both into
and out of it but am having trouble getting it to work the way the
documentation indicates it should and I am hoping somebody will be able to
help me.
My instance of IDataObject supports CF_HDROP and CFTSR_PREFERREDDROPEFFECT
from GetData and CFTSR_PERFORMEDDROPEFFECT and CFSTR_PASTESUCCEEDED from
SetData.
When I drag an item from my namespace to the desktop DoDragDrop returns
DROPEFFECT_NONE and my data object's SetData function is called with
CFSTR_PERFORMEDDROPEFFECT set to DROPEFFECT_MOVE.  This isn't exactly what
is supposed to happen according to the documentation, but it's not a
problem.
However, when I copy something from my namespace and paste it to the desktop
my SetData function is never called.  The documentation indicates it should
call it with both of the formats I support if the paste actually succeeds.
I need to know if the paste succeeds in case a cut operation has ocurred so
I can update inside my namespace.  So, how DOES the shell notify my data
object that a paste succeeded?
For that matter, when I try and notify the shell that a paste operation I
have done with it's data object has worked the process doesn't work like the
documentation indicates.  My call to SetData with CFSTR_PERFORMEDDROPEFFECT
is rejected with E_INVALIDARG but my call with CFSTER_PASTESUCCEEDED works
and the shell deletes the files as it should.  The two calls differ only in
the cfFormat member that is used.  This becomes a problem when supporting
dragging files onto my namespace.  How am I supposed to notify the shell
that the drag-and-drop operation succeeded and it should delete the files in
question?
So my questions are:
1)  How am I supposed to know when the shell has successfully done a paste
operation with my data object?
2)  How am I supposed to communicate to the shell when I have done a paste
or drop operation with one of it's data objects?

If anybody can help me I would appreciate it,
Pat

 
 
 

implementing IDataObject

Post by Mumtaz Zahee » Wed, 28 Jun 2000 04:00:00



>>When I drag an item from my namespace to the desktop
>>DoDragDrop returns DROPEFFECT_NONE and my data object's
>>SetData function is called with CFSTR_PERFORMEDDROPEFFECT
>>set to DROPEFFECT_MOVE.  This isn't exactly what is
>>supposed to happen according to the documentation, but
>>it's not a problem.

DROPEFFECT_NONE means target don't accept the data???
Are u giving DROPEFFECT_COPY | DROPEFFECT_MOVE in third
parameter of DoDragDrop();

Quote:>>However, when I copy something from my namespace and paste
>>it to the desktop my SetData function is never called.  The
>>documentation indicates it should call it with both of the
>>formats I support if the paste actually succeeds.
>>I need to know if the paste succeeds in case a cut
>>operation has occurred so I can update inside my namespace.  So,
>>how DOES the shell notify my data object that a paste succeeded?

It seems if you are not managing the PREFFEREDDROPEFFECT , it should be
like this (writing code may looks unnecessary)

UINT cbFormat = RegisterClipboardFormat(CFSTR_PREFERREDDROPEFFECT);
HGLOBAL hGlobal = GlobalAlloc(GMEM_SHAR, sizeof(DWORD));
Long *pDropEffect = (long *)GlobalLock(hGlobal);
*pDropEffect = DROPEFFECT_????;
GlobalUnlock(hGlobal);
OpenClipboard(NULL);
.
.
.
SetClipboardData(CF_HDROP, ----);
SetClipboardData(cbFormat, hGlobal);
CloseClipboard();

Actually, I wrote above code as I am not an expert, this is the way I did that.

------

Quote:>>So my questions are:
>>1. How am I supposed to know when the shell has successfully done
>>a paste   operation with my data object?

You must get the call to your SetData() if you specified
PREFERREDDROPEFFECT successfully.

Quote:>>2. How am I supposed to communicate to the shell when I
>>have done a paste or drop operation with one of its data objects?

As You know we get the dropeffect in IDropTarget::Drop();
Try to do same as you are doing with calling source DataObject::SetData() with
CFSTER_PASTESUCCEEDED ;
OR you have the choice to delete the source by your self...

Hope we can solve it.

Mumtaz.

 
 
 

implementing IDataObject

Post by Patrick Barr » Thu, 29 Jun 2000 04:00:00


Thanks for replying to my question.  More below...

Quote:> DROPEFFECT_NONE means target don't accept the data???

That would seem logical I guess but the documentation does not say that is
the case.  It may be set to that when an un-optimized move has taken place,
for instance.  The documentation even specifically mentions how unreliable
this is.

Quote:> Are u giving DROPEFFECT_COPY | DROPEFFECT_MOVE in third
> parameter of DoDragDrop();

Yes indeed.

Quote:> It seems if you are not managing the PREFFEREDDROPEFFECT , it should be
> like this (writing code may looks unnecessary)

I am managing it, though perhaps not correctly.  I do provide that format
and I can see the shell getting it from me.

Quote:> UINT cbFormat = RegisterClipboardFormat(CFSTR_PREFERREDDROPEFFECT);
> HGLOBAL hGlobal = GlobalAlloc(GMEM_SHAR, sizeof(DWORD));
> Long *pDropEffect = (long *)GlobalLock(hGlobal);
> *pDropEffect = DROPEFFECT_????;
> GlobalUnlock(hGlobal);
> OpenClipboard(NULL);
> SetClipboardData(CF_HDROP, ----);
> SetClipboardData(cbFormat, hGlobal);
> CloseClipboard();
> Actually, I wrote above code as I am not an expert, this is the way I did

that.

I am using an implementation of the IDataObject COM interface, but I did it
essentially the way you just did.

Quote:> >>1. How am I supposed to know when the shell has successfully done
> >>a paste   operation with my data object?
> You must get the call to your SetData() if you specified
> PREFERREDDROPEFFECT successfully.

I think I set it correctly.  I set it to DROPEFFECT_COPY for a copy and
DROPEFFECT_MOVE for a cut-and-paste.

Quote:> >>2. How am I supposed to communicate to the shell when I
> >>have done a paste or drop operation with one of its data objects?
> As You know we get the dropeffect in IDropTarget::Drop();
> Try to do same as you are doing with calling source DataObject::SetData()
with
> CFSTER_PASTESUCCEEDED ;
> OR you have the choice to delete the source by your self...

I haven't tried to call SetData with CFSTR_PASTESUCCEEDED when I am
accepting a dropped item.  I'll have to try that.
Thanks,
Pat Barry
 
 
 

1. Implementing IDataObject in a VB-UserControl

Hello!

I need to implement the interface IDataObject in a VB-UserControl. I wrote
an odl-file with the definition of it, compiled it
and linked the tlb with my project. In the ctl-file I implement the
interface with "Implements IVBDataObject". I also overwrote
all the procedurs of the interface. So far so good.
But now the problem: If I define the interface in the odl-file like the
following, it works fine, but I can't return a value in VB:
....
HRESULT SetData(....)        // without [out,retval] long* ret
....

So I tried following:
....
long SetData(....)        // without [out,retval] long* ret
....
Now I can't implement the interface, because the return-value isn't
HRESULT-type.

My last try:
....
HRESULT SetData(...., [out,retval] long* ret)
....

Now I can return a value, but VB crashes everytime the overwritten procedure
is called.

Can anyone help me?
Thanks!

2. Adding Win ME Client to SBS 4.5

3. How to implement delayed rendering with IDataObject?

4. W2k Pro looses ip stack at random

5. IDataObject and IShellView created by SHCreateShellFolderView

6. scan disc on start up

7. IDataObject

8. Image dropshadows

9. IDataObject::GetData called when closing Explorer

10. IDataObject problem in Shell NSE

11. IDropSourceHelper and IDataObject

12. Why is ICommDlgBrowser calling IDataObject::GetData?

13. baby alarm system implemented on PC