In 3.91 the interface is defined, BUT : how to get a pointer to this interface? Where to find the IID? I can not figure out how to do a (simple?) OLE drag'n drop in Purebasic...
I know what is needed : IDataObject/IDropSource/OleInitialize And DoDragDrop.....but, that's about it.
Please.....
IDataObject - interface
-
- PureBasic Expert
- Posts: 2812
- Joined: Fri Apr 25, 2003 4:51 pm
- Location: Portugal, Lisbon
- Contact:
Just use these function instead:
Code: Select all
Procedure.l DropFiles ()
ProcedureReturn EventwParam ()
EndProcedure
;
Procedure GetNumDropFiles (*dropFiles)
ProcedureReturn DragQueryFile_ (*dropFiles, $FFFFFFFF, temp$, 0)
EndProcedure
;
Procedure.s GetDropFile (*dropFiles, index)
bufferNeeded = DragQueryFile_ (*dropFiles, index, 0, 0)
For a = 1 To bufferNeeded: buffer$ + " ": Next ; Short by one character!
DragQueryFile_ (*dropFiles, index, buffer$, bufferNeeded+1)
ProcedureReturn buffer$
EndProcedure
;
Procedure FreeDropFiles (*dropFiles)
DragFinish_ (*dropFiles)
EndProcedure
;//// USAGE //////
DragAcceptFiles_ (WindowID(), 1) ;/// make our window accept d'n'd
;/// Drop File Event
If Event=#WM_DROPFILES
*dropped = DropFiles ()
open.s=GetDropFile(*dropped,0)
FreeDropFiles (*dropped)
debug "First file dropped "+open
EndIf
How to make a gadget accept dropped files, e. g. a ListIcon (or any other gadget?
PB 4.30
Code: Select all
onErrorGoto(?Fred)
Code: Select all
Global gOldListProc
;Subclasses the list icon gadget.
Procedure listiconcallback(hWnd,uMsg,wParam,lParam)
Protected ReturnValue, numfiles, buffer$
Select uMsg
Case #WM_DROPFILES
*dropped = wParam
numfiles = DragQueryFile_(wParam , -1, 0, 0)
For i = 0 To numfiles - 1
buffer$=Space(DragQueryFile_(*dropped, i, 0, 0)+1)
DragQueryFile_ (*dropped, i, buffer$, Len(buffer$))
AddGadgetItem(1, -1, buffer$)
Next
DragFinish_(*dropped)
ReturnValue = CallWindowProc_(gOldListProc, hWnd, uMsg, wParam, lParam)
Default
ReturnValue = CallWindowProc_(gOldListProc, hWnd, uMsg, wParam, lParam)
EndSelect
ProcedureReturn ReturnValue
EndProcedure
If OpenWindow(0, 0, 0, 300, 300, "Drag 'n' drop",#PB_Window_SystemMenu|#PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0))
ListIconGadget(1, 50,50, 200,200, "Files", 150)
DragAcceptFiles_(GadgetID(1), 1)
gOldListProc = SetWindowLong_(GadgetID(1), #GWL_WNDPROC, @listiconcallback())
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Quit = 1
EndSelect
Until Quit = 1
EndIf
End
I may look like a mule, but I'm not a complete ass.