News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Drag And Drop

Started by ernest33, November 16, 2006, 03:06:25 PM

Previous topic - Next topic

ernest33

Hello  :bg
I'm playing around with drag & drop to get a pidl from any system object.
I've done all work to get drop handler working, but i can't get the pidl from STGMEDIUM.hGlobal...
I have found this
         ;#define HIDA_GetPIDLFolder(pida) (LPCITEMIDLIST)(((LPBYTE)pida)+(pida)->aoffset[0])
         ;#define HIDA_GetPIDLItem(pida, i) (LPCITEMIDLIST)(((LPBYTE)pida)+(pida)->aoffset[i+1])

in the msdn SDK, but don't find the way to translate that in masm  :dazzled:.

Could someone have a clue to help me  :bg please.

Best regards
Philippe

PS : I've already done that in Pascal & C++, i was thinking it will be easy to port to masm but  :naughty:

ToutEnMasm

Hello,
The clue is ......... to use c++ code and disassemble it .
Perhaps also if you give the name of the heaser,this could help
                          ToutEnMasm

ernest33

 :green
Hi ToutEnMasm the header is "shlobj.h".

I'm using the 'DragDropObj.asm' by Ketilo to handle D&D in masm. I'm modifing the "IDropTarget_Drop" to be able to get an ITEMIDLIST.
I think i'm in the good direction because i got a good CIDA structure (i have the right number of items when i drop something [number of items in CIDA.cidl]).
The problem is to extract the data from CIDA.aoffset which is an array of offset to got the pidl  :dazzled:.


;medium is STGMEDIUM struct.
;pida is ptr to CIDA struct.
;all of them found in shlobj.h

invoke GlobalSize,medium.hGlobal
mov pidlsize,eax
push ebx
invoke GlobalLock,medium.hGlobal
mov ebx,eax
assume ebx:ptr CIDA
mov pida,ebx
assume ebx:nothing
mov ebx,pida
assume ebx:ptr CIDA   ;now i have good CIDA in ebx

the problem is to use CIDA.aoffset dd 1 dup(?).


I'll take a look about disassembling a c++ program but i know i'm a newbies...anyway there's nothing impossible  :dance:

Ernest33 :bg

diablo2oo2

i don't know if you are askining for this. but it might be also useful. i have coded procedure which detects if something was dropped into a certain control in a dialogbox.

align 16
DragInControl proc _hdrop:dword,_dlg_handle:dword,_control_id:dword

LOCAL local_retvalue :byte
LOCAL item_rect :RECT
LOCAL pt :POINT

pushad

lea esi,item_rect
lea ebx,pt

assume esi:ptr RECT
assume ebx:ptr POINT

mov local_retvalue,0

invoke GetDlgItem,_dlg_handle,_control_id ;get handle of item
invoke GetWindowRect,eax,esi ;get x,y position and size of the item
invoke GetCursorPos,ebx

invoke PtInRect,esi,[ebx].x,[ebx].y
.if eax
mov local_retvalue,1 ;file was dropped into this item
.endif

assume esi:nothing
assume ebx:nothing

popad
movzx eax,local_retvalue ;1=dragged into control else 0
ret
DragInControl endp



usage:
...
.elseif message==WM_DROPFILES
;---query drop---
lea esi,local_buffer ;recieves filepath
invoke DragQueryFile,wparam,0,esi,sizeof local_buffer ;return lenght

;---check---
invoke DragInControl,wparam,hwnd,EDIT_BOX
.if eax==1
;file was dropped into this control
.endif

;---free memory--
invoke DragFinish,wparam
...

ernest33

Thank diablo2oo2. Very interristing.
But this code is only able to retrieve information of normal file. The thing i want to do with masm is to be able to get a system element like "My Computer" or "Network connection" (these are some kind of virtual element). I already done that in c++ & Pascal.
I hope i finally find an answer by myself or with the help of someone. I will really happy to put what i found here to maybe help someone else  :wink

Ernest33

ToutEnMasm

Hello,
It's more clear now.
It seems  that there is a more simple way to do this

invoke SHGetSpecialFolderPath,hWnd,addr chemin,CSIDL_Something,NULL

            ToutEnMasm

ernest33

Hello ToutEnMasm :bg
This is useful...when you have a PIDL which point to a special folder with a real path. It don't work for "My Computer" or "Printers".
In my case i don't have yet PIDL, it is in the structure CIDA i got from a drag&drop. What i need is a way to get the pidl.
What i know :
CIDA.cidl is the number of dropped objects
CIDA.aoffset(?) containt the pidl(s)

What i understand about getting the pidl :
CIDA + CIDA.aoffet(0) containt the root of the pidl of the parent folder.
CIDA + CIDA.aoffet(i+1) containt the pidl

I hope i'm enough clear because my english is not very good  ::)

Ernest33

drizz

it would translate to something like this...
HIDA_GetPIDLFolder macro pida:req
mov eax,pida
exitm <[eax].CIDA.aoffset[0*4]>
endm

HIDA_GetPIDLItem macro pida:req, i:req
mov eax,pida
exitm <[eax].CIDA.aoffset[i*4+1*4]>
endm

------------------
mov esi,HIDA_GetPIDLFolder(pida)
mov edi,HIDA_GetPIDLItem(pida,2)
assume esi:LPCITEMIDLIST,edi:LPCITEMIDLIST

assume esi:nothing, edi:nothing
The truth cannot be learned ... it can only be recognized.

ernest33

Great drizz !!
I'm now back on the road. Thanks a lot :clap:
I have some works to do and i'll put the final here  :bg . I hope this will help someone too  :toothy

Ernest33