Current version

v1.10.4 (stable)

Navigation

Main page
Archived news
Downloads
Documentation
   Capture
   Compiling
   Processing
   Crashes
Features
Filters
Plugin SDK
Knowledge base
Contact info
Forum
 
Other projects
   Altirra

Search

Archives

01 Dec - 31 Dec 2013
01 Oct - 31 Oct 2013
01 Aug - 31 Aug 2013
01 May - 31 May 2013
01 Mar - 31 Mar 2013
01 Feb - 29 Feb 2013
01 Dec - 31 Dec 2012
01 Nov - 30 Nov 2012
01 Oct - 31 Oct 2012
01 Sep - 30 Sep 2012
01 Aug - 31 Aug 2012
01 June - 30 June 2012
01 May - 31 May 2012
01 Apr - 30 Apr 2012
01 Dec - 31 Dec 2011
01 Nov - 30 Nov 2011
01 Oct - 31 Oct 2011
01 Sep - 30 Sep 2011
01 Aug - 31 Aug 2011
01 Jul - 31 Jul 2011
01 June - 30 June 2011
01 May - 31 May 2011
01 Apr - 30 Apr 2011
01 Mar - 31 Mar 2011
01 Feb - 29 Feb 2011
01 Jan - 31 Jan 2011
01 Dec - 31 Dec 2010
01 Nov - 30 Nov 2010
01 Oct - 31 Oct 2010
01 Sep - 30 Sep 2010
01 Aug - 31 Aug 2010
01 Jul - 31 Jul 2010
01 June - 30 June 2010
01 May - 31 May 2010
01 Apr - 30 Apr 2010
01 Mar - 31 Mar 2010
01 Feb - 29 Feb 2010
01 Jan - 31 Jan 2010
01 Dec - 31 Dec 2009
01 Nov - 30 Nov 2009
01 Oct - 31 Oct 2009
01 Sep - 30 Sep 2009
01 Aug - 31 Aug 2009
01 Jul - 31 Jul 2009
01 June - 30 June 2009
01 May - 31 May 2009
01 Apr - 30 Apr 2009
01 Mar - 31 Mar 2009
01 Feb - 29 Feb 2009
01 Jan - 31 Jan 2009
01 Dec - 31 Dec 2008
01 Nov - 30 Nov 2008
01 Oct - 31 Oct 2008
01 Sep - 30 Sep 2008
01 Aug - 31 Aug 2008
01 Jul - 31 Jul 2008
01 June - 30 June 2008
01 May - 31 May 2008
01 Apr - 30 Apr 2008
01 Mar - 31 Mar 2008
01 Feb - 29 Feb 2008
01 Jan - 31 Jan 2008
01 Dec - 31 Dec 2007
01 Nov - 30 Nov 2007
01 Oct - 31 Oct 2007
01 Sep - 30 Sep 2007
01 Aug - 31 Aug 2007
01 Jul - 31 Jul 2007
01 June - 30 June 2007
01 May - 31 May 2007
01 Apr - 30 Apr 2007
01 Mar - 31 Mar 2007
01 Feb - 29 Feb 2007
01 Jan - 31 Jan 2007
01 Dec - 31 Dec 2006
01 Nov - 30 Nov 2006
01 Oct - 31 Oct 2006
01 Sep - 30 Sep 2006
01 Aug - 31 Aug 2006
01 Jul - 31 Jul 2006
01 June - 30 June 2006
01 May - 31 May 2006
01 Apr - 30 Apr 2006
01 Mar - 31 Mar 2006
01 Feb - 29 Feb 2006
01 Jan - 31 Jan 2006
01 Dec - 31 Dec 2005
01 Nov - 30 Nov 2005
01 Oct - 31 Oct 2005
01 Sep - 30 Sep 2005
01 Aug - 31 Aug 2005
01 Jul - 31 Jul 2005
01 June - 30 June 2005
01 May - 31 May 2005
01 Apr - 30 Apr 2005
01 Mar - 31 Mar 2005
01 Feb - 29 Feb 2005
01 Jan - 31 Jan 2005
01 Dec - 31 Dec 2004
01 Nov - 30 Nov 2004
01 Oct - 31 Oct 2004
01 Sep - 30 Sep 2004
01 Aug - 31 Aug 2004

Stuff

Powered by Pivot  
XML: RSS feed 
XML: Atom feed 

§ Drag-and-drop RTFM... no dice.

Either I need a better collection of books, or I have a habit of hitting weird problems.

I've been experimenting with drag-and-drop between an application and the Windows shell, and managed to get virtual objects dragging to the shell working without too much trouble. However, the opposite direction -- dragging from the shell to the application -- is refusing to work. I've been trying to accept the CFSTR_FILEDESCRIPTOR / CFSTR_FILECONTENTS pair of formats, and was scratching my head trying to figure out why IDataObject::QueryGetData() kept succeeding, but IDataObject::GetData() with the same format request kept failing. As usual, the Platform SDK documentation has shown to be a bit less than truthful and I've had to fill in bits from more reputable sources (i.e. The Old New Thing) and then just plain experimentation.

The first case that was giving me problems was the plain file drop case, until I figured out two things. The first was that I was looking for the wrong clipboard format; straight file drops use CF_HDROP and a list of filenames instead of the descriptor/contents pairing. OK, fair enough. What took me longer to figure out was why QueryGetData() was "succeeding": it was actually returning S_FALSE instead of an error code for unsupported formats. This makes sense, except that it's not documented behavior. I have a habit of using the SUCCEEDED() macro for HRESULT values instead of comparing against S_OK under the belief that that is the more correct behavior, but after getting burnt multiple times I'm beginning to wonder if the other way is safer.

The second and uglier case was the virtual-to-virtual case, specifically dragging from a .zip file. In this case there is no direct file on disk, so the shell extension handling .zip files passes the data through a channel instead. The CFSTR_FILEDESCRIPTOR format tells you the metadata for the files, and the CFSTR_FILECONTENTS format is used to extract the actual files. However, the docs don't mention anywhere that there are both narrow and wide versions of the former (CFSTR_FILEDESCRIPTORA/CFSTR_FILEDESCRIPTORW) and the OS apparently does not support both or convert between them automatically. This means that if you just use CFSTR_FILEDESCRIPTOR as recommended you will actually get different behavior depending on whether you compile as Unicode or MBCS. On Windows 7 x64, I'm only seeing the request for the wide version succeeding, and although I can't test it, I suspect that with some other programs or possibly on Windows 9x I would only see the narrow format available. The best conclusion I can draw from this is that the procedure in the Platform SDK docs for handling this format in a drop target is fatally incomplete and you actually have to support both formats. What a mess!

Anyone dealt with implementing drag-and-drop file targets before? I'd love to hear if what I've said above is correct.

Comments

Comments posted:


Yes, you have to support both formats. It's not even a given that on Windows 7 you'll always get the wide formats - you will from Explorer, but other apps may only support the narrow format.

jon (link) - 01 01 11 - 18:41


Thanks for the confirmation. I guess I should have saved some of those "Guaranteed Not To Work" stickers from Weird Stuff Warehouse so I could stick them on parts of MSDN.

Phaeron - 01 01 11 - 18:58


Off topic, you might want to update your latest version on the top left of the page.

evropej - 06 01 11 - 15:28


Indeed, if I remember well the SUCCEEDED just tells you the API didn't fail to return a result. You should check for S_OK

George Birbilis (link) - 07 01 11 - 01:12


> Indeed, if I remember well the SUCCEEDED just tells you the API didn't fail to return a result. You should check for S_OK

This is counter to the advice given by Microsoft's COM documentation.

http://msdn.microsoft.com/en-us/library/..

"All of the constants with the prefix "E_" are error codes. The constants S_OK and S_FALSE are both success codes. Probably 99% of COM methods return S_OK when they succeed; but do not let this fact mislead you. A method might return other success codes, so always test for errors by using the SUCCEEDED or FAILED macro."

It goes on to say:

"The success code S_FALSE deserves mention. Some methods use S_FALSE to mean, roughly, a negative condition that is not a failure. It can also indicate a "no-op"—the method succeeded, but had no effect. For example, the CoInitializeEx function returns S_FALSE if you call it a second time from the same thread. If you need to differentiate between S_OK and S_FALSE in your code, you should test the value directly, but still use FAILED or SUCCEEDED to handle the remaining cases, as shown in the following example code."

Basically, this comes down to appropriate uses of non-S_OK success return values. At the very least, it seems that returning S_FALSE as an undocumented return code when it does not accompany the same returned data as S_OK is questionable implementation.

Phaeron - 07 01 11 - 16:46

Comment form


Please keep comments on-topic for this entry. If you have unrelated comments about VirtualDub, the forum is a better place to post them.
Name:  
Remember personal info?

Email (Optional):
Your email address is only revealed to the blog owner and is not shown to the public.
URL (Optional):
Comment: /

An authentication dialog may appear when you click Post Comment. Simply type in "post" as the user and "now" as the password. I have had to do this to stop automated comment spam.



Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.