[COM] Help with the IDropSource and IDropTarget interfaces

Get help with using AutoHotkey and its commands and hotkeys
zcooler
Posts: 381
Joined: 11 Jan 2014, 04:59

Re: [COM] Help with the IDropSource and IDropTarget interfaces

18 Mar 2017, 11:52

Hi Just me,
Initial DragImage D&D implementation tries in my big app did get abrupted by a couple of errormsg followed by a nasty crash of AHK_H when dropping a file (with dragimage) at a in-treeview folder. To rule out any implicating factors in my script I tried to implement it into the demo I posted above, with same crashing result. Dont know if it might be an AHK_H bug or some of the COM coding.

The two error msgboxes says:
---------------------------
AutoHotkey
---------------------------
Error: CONTINUABLE EXCEPTION_ACCESS_VIOLATION

Mouse and Keyboard hooks have been disabled.

- Press yes to exit thread and continue execution.
- Press no to continue thread (debug).
- Press cancel to exit application.

Exception was caused in thread id: 9352
Line: 14
LineFile: F:\TV\test\MediaLauncher\IDataObject.ahk
---------------------------
Ja Nej Avbryt
---------------------------
---------------------------
AutoHotkey
---------------------------
Error: CONTINUABLE EXCEPTION_ACCESS_VIOLATION

Mouse and Keyboard hooks have been disabled.

- Press yes to exit thread and continue execution.
- Press no to continue thread (debug).
- Press cancel to exit application.

Exception was caused in thread id: 9352
Line: 51
LineFile: F:\TV\test\MediaLauncher\SHDoDragDrop.ahk
---------------------------
Ja Nej Avbryt
---------------------------


Regards
zcooler
just me
Posts: 4361
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [COM] Help with the IDropSource and IDropTarget interfaces

19 Mar 2017, 09:09

It seems to be a problem only occurring if the drag initiator and the drop target belong to the same thread. In this case, the pointer to the data object seems to be invalid when SHDoDragDrop returns, and the script crashes in AHK 1.1, too.

It might be related to 'unsave' thread interruption caused by RegisterCallback(), but I'm just guessing. It's a pitty.
zcooler
Posts: 381
Joined: 11 Jan 2014, 04:59

Re: [COM] Help with the IDropSource and IDropTarget interfaces

19 Mar 2017, 09:41

just me wrote:It's a pitty.
Just me, much kudos for the very nice try and the huge amount of time you must have spent on this mega complex "kick-ass" D&D interface. One cannot win em all ;) Hats off to you, Sir :salute:
just me
Posts: 4361
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [COM] Help with the IDropSource and IDropTarget interfaces

19 Mar 2017, 10:08

Silly me! It seems to be a bug implemented since the first version of IDropTarget but without observable consequences until now. Remove the line
from IDropTarget.Drop(...) and try again, please.
zcooler
Posts: 381
Joined: 11 Jan 2014, 04:59

Re: [COM] Help with the IDropSource and IDropTarget interfaces

19 Mar 2017, 10:48

OHHH YES, now we are talking niiicee DragImages :mrgreen: Sooo, very cool :lol:
Hmm...Im not there yet but just to make sure for future references and while the great author is spending time on it :) I do wonder if the SHDoDragDrop() might accept md5 hash tags as DragImage (which the windows explorer thumbnails are stored in I think anyway (in the windows thumbnail cache folder .db files))?

These thumbnails are located in encrypted .db files and there is no way to access em what I know of. Trying to load the hash didnt work. Any better ideas?

Found some code for md5 hash generating:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



Best regards
zcooler :wave:
zcooler
Posts: 381
Joined: 11 Jan 2014, 04:59

Re: [COM] Help with the IDropSource and IDropTarget interfaces

19 Mar 2017, 12:12

Hi again just me :)

Tested quite extensively multiple ways to pass system assocciated icons to SHDoDragDrop(), which are loaded/added into the treeview GUI script, but everything I tried failed. The system's icons for the extensions are added using the default size SYSSMALL, so I could pick up which icon belongs to which extension on the fly, but when trying to pass them as a DragImage it doesnt work. Well, i dont wanna pass them as DragImages, instead I do wanna display the Icon blended into the otherwise empty DragImage, like the explorer way, but that doesnt seem to be possible, yes?

Regards
zcooler
just me
Posts: 4361
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [COM] Help with the IDropSource and IDropTarget interfaces

20 Mar 2017, 03:56

Hi zcooler,

Code: [Select all] [Download] (SHDoDragDrop.ahk)GeSHi © Codebox Plus

;     DragImage            -  SHDoDragDrop (API) uses a default drag image if no other option is available. You may pass:
; - a HWND of a window or control which will create an own drag image in response to the
; DI_GETDRAGIMAGE message (e.g. ListViews and TreeViews support this message).
; - a HBITMAP handle of a bitmap to be used as the drag image.

  1. You cannot pass anything else than a HWND or HBITMAP handle.
  2. You cannot pass a handle to be combined with the shell's default drag image. It will be replaced.
zcooler wrote:Well, i dont wanna pass them as DragImages, instead I do wanna display the Icon blended into the otherwise empty DragImage, like the explorer way, but that doesnt seem to be possible, yes?
It might be possible, but afaik you'd have to do it by yourself. ;)
just me
Posts: 4361
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [COM] Help with the IDropSource and IDropTarget interfaces

20 Mar 2017, 11:55

You might want to try this function:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

It returnes a HBITMAP handle on success which can be passed to SHDoDragDrop() as a drag image. But it still won't look like 'the explorer way,'. ;)
zcooler
Posts: 381
Joined: 11 Jan 2014, 04:59

Re: [COM] Help with the IDropSource and IDropTarget interfaces

21 Mar 2017, 14:24

just me wrote:You might want to try this function:
Yes, much obliged, Just me :D It returns most thumbnails and icons on the fly, but I had problems to get the video thumbnails. Turns out my explorer thumbnail generator for video files (not all video format thumbnails are supported by default in the explorer) didnt create the thumbnails as long as using the "detailed listview". I had to change it to either "medium sized icon" or "large sized icons" for all video folders and then the thumbnails are created in the explorer and turns up as dragimages using SHDoDragDrop() in the ahk app (before this move only the icon was returned for these video files). I have to find a new explorer thumnail generator cuz the old one does not create new thumbnails for recently added recordings, despite having large sized icons set for the folder. You have to browse the videofolder in the explorer in order to start thumbnail generation for the new files in there :( Took some time to figure it out.

just me wrote:It returns a HBITMAP handle on success which can be passed to SHDoDragDrop() as a drag image. But it still won't look like 'the explorer way,'. ;)
Well, it is pretty close though...but without the fancy stuff the explorer thumbnail generator adds (picture framing and minimized file extension icon) when creating the thumbnail ;) Unfortunately when using thumbnails and icons as dragimages, the drop-effect description text is lost. While the bluish drag-image without any content (passing NULL as drag source object) does have the drop-effect description text. Maybe you could explain in more detail why it is not possible to put the thumbnails and icons inside the bluish drag-image? That information could be very helpful for savvy folks in here who might wanna take a crack at filling the bluish drag-images with content, with working drop-effect description text.

Regards
zcooler
just me
Posts: 4361
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [COM] Help with the IDropSource and IDropTarget interfaces

22 Mar 2017, 07:06

Hi zcooler,

Maybe you could explain in more detail why it is not possible to put the thumbnails and icons inside the bluish drag-image?
Because the shell will use either the bluish default drag image or the passed drag image. It should be possible to combine them, but the shell simply doesn't. If you want to have a default style drag image with additional content you have to create an appopriate bitmap and pass its handle.
zcooler
Posts: 381
Joined: 11 Jan 2014, 04:59

Re: [COM] Help with the IDropSource and IDropTarget interfaces

22 Mar 2017, 08:11

just me wrote:Hi zcooler,

Maybe you could explain in more detail why it is not possible to put the thumbnails and icons inside the bluish drag-image?
Because the shell will use either the bluish default drag image or the passed drag image. It should be possible to combine them, but the shell simply doesn't. If you want to have a default style drag image with additional content you have to create an appopriate bitmap and pass its handle.
Moin Just me,
Yes, it is obvious its not possible to combine them, had hoped for more technical COM details what happens when trying to combine according to MS regulations (maybe MS documentation about how to do here is non-existant), but its fine without them. No, I wont even try to create an appropiate bitmap and pass its handle, cuz the drop-effect description text wont work for those anyway (it might be interesting to do this at first when/if combining works). I will use the bluish empty default drag image all the time, with drop-effect description text working, cuz together they provide the best visible proof a drag operation has been initialized correctly (that was all along the main objective for me with these drag images, when starting posting about it in this thread). The fancy image stuff is just "icing on the cake". You will never know someone might, on a fine day, find a loophole and in that way manage to succeed with combining.

Thanks for your great work, Just me :wave:

Best regards
zcooler

Return to “Ask For Help”

Who is online

Users browsing this forum: iceivanov, ozzii, Yahoo [Bot] and 50 guests