IDataObject - interface

Just starting out? Need help? Post your questions and find answers here.
eriansa
Enthusiast
Enthusiast
Posts: 277
Joined: Wed Mar 17, 2004 12:31 am
Contact:

IDataObject - interface

Post 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.....
eriansa
Enthusiast
Enthusiast
Posts: 277
Joined: Wed Mar 17, 2004 12:31 am
Contact:

Post by eriansa »

someone somewhere?
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post 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

eriansa
Enthusiast
Enthusiast
Posts: 277
Joined: Wed Mar 17, 2004 12:31 am
Contact:

Post by eriansa »

That example is to drop on a PB program. I want to drag from PB to an external program...
AND51
Addict
Addict
Posts: 1040
Joined: Sun Oct 15, 2006 8:56 pm
Location: Germany
Contact:

Post by AND51 »

How to make a gadget accept dropped files, e. g. a ListIcon (or any other gadget?
PB 4.30

Code: Select all

onErrorGoto(?Fred)
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post 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
I may look like a mule, but I'm not a complete ass.
AND51
Addict
Addict
Posts: 1040
Joined: Sun Oct 15, 2006 8:56 pm
Location: Germany
Contact:

Post by AND51 »

Oh, thank you!! :o
PB 4.30

Code: Select all

onErrorGoto(?Fred)
Post Reply