EUREKA!!! I got the neurons firing!

But I've finally reached my goal!!!
One small step
for the community, one giant leap
for me!
@AZIJO
There was an error in the code
for the first link you provided.
The variable Dropped was typed .l instead of .i. On a 32-bit system, no issue, but it didn't work on x64. So I replaced the type with .i (equivalent to .q under x64) and now it works.
Thanks to AZIJO, RASHAD and all those who worked so hard before me to produce code on this subject.
So, below is my working code with detection of the gadget that received the drop action.
Code: Select all
EnableExplicit
;
If OSVersion()<#PB_OS_Windows_Vista
MessageRequester("","This code only runs on Windows Vista Or above",#PB_MessageRequester_Error)
End
EndIf
Define.s XMLString
Runtime Enumeration
#String
#Text
EndEnumeration
;
XMLString="<?xml version='1.0' encoding='UTF-16'?>"+Chr(10)+ ;{
"<dialogs>"+Chr(10)+
" <window id='0' name='Window1' text='Test' xpos='0' ypos='0' flags='#PB_Window_SystemMenu|#PB_Window_ScreenCentered'>"+Chr(10)+
" <vbox>"+Chr(10)+
" <string id='#String' name='String' text='String gadget : Drop file here...' width='400'/>"+Chr(10)+
" <text id='#Text' name='Text' text='Text gadget : Drop file here...' width='400'/>"+Chr(10)+
" </vbox> "+Chr(10)+
" </window>"+Chr(10)+
"</dialogs>" ;}
;
ParseXML(0,XMLString)
CreateDialog(0)
OpenXMLDialog(0,0,"Window1",0,0,0,0)
ChangeWindowMessageFilter_(#WM_DROPFILES,#MSGFLT_ADD)
ChangeWindowMessageFilter_(#WM_COPYDATA, #MSGFLT_ADD)
ChangeWindowMessageFilter_(73, #MSGFLT_ADD)
SetWindowLongPtr_(GadgetID(#String),#GWL_EXSTYLE,GetWindowLongPtr_(GadgetID(#String),#GWL_EXSTYLE)|#WS_EX_ACCEPTFILES)
SetWindowLongPtr_(GadgetID(#Text),#GWL_EXSTYLE,GetWindowLongPtr_(GadgetID(#Text),#GWL_EXSTYLE)|#WS_EX_ACCEPTFILES)
;
Define.i Dropped,HGadget
Define.l NumberOfFiles,Count,StringLength,GadgetNumber
Define.s FileName,FileNameWanted
Define.POINT PosCursor
;
Repeat
Select WaitWindowEvent()
Case #WM_DROPFILES ; Vista and above
Debug EventGadget()
GetCursorPos_(@PosCursor)
HGadget=WindowFromPoint_(PeekQ(@PosCursor))
GadgetNumber=GetProp_(HGadget,"PB_WindowID")
Select GadgetNumber
Case #String:Debug "Gadget #String dropped"
Case #Text:Debug "Gadget #Text dropped"
EndSelect
Dropped=EventwParam()
NumberOfFiles=DragQueryFile_(Dropped,-1,"",0)
If NumberOfFiles
For Count=0 To NumberOfFiles-1
StringLength=DragQueryFile_(Dropped,Count,0,0)
FileName=Space(StringLength)
DragQueryFile_(Dropped,Count,FileName,StringLength+1)
Debug "File #"+Count+" dropped : "+FileName
If Count=0 ; I want only the first file for demonstration
FileNameWanted=FileName
EndIf
Next
DragFinish_(Dropped)
Debug "File wanted : "+FileNameWanted
SetGadgetText(GadgetNumber,FileNameWanted)
EndIf
Case #PB_Event_CloseWindow
Break
EndSelect
ForEver