Page 1 of 1

IDataObject - interface

Posted: Mon Aug 16, 2004 7:59 am
by eriansa
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.....

Posted: Mon Aug 30, 2004 6:36 pm
by eriansa
someone somewhere?

Posted: Mon Aug 30, 2004 7:59 pm
by Num3
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


Posted: Mon Aug 30, 2004 8:48 pm
by eriansa
That example is to drop on a PB program. I want to drag from PB to an external program...

Posted: Mon Jan 15, 2007 7:35 pm
by AND51
How to make a gadget accept dropped files, e. g. a ListIcon (or any other gadget?

Posted: Mon Jan 15, 2007 8:36 pm
by srod

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

Posted: Tue Jan 16, 2007 8:45 pm
by AND51
Oh, thank you!! :o