Drag and Drop

BlitzMax Forums/BlitzMax Programming/Drag and Drop

Filax(Posted 2007) [#1]
Hi

I get a problem with drag and drop. It is possible
to get each drag n dropped files one by one ?

Actually i'm using this, the problem is that the returned
information is ony one string. Is there a command to
extract each filename ?

Thanks




fredborg(Posted 2007) [#2]
SuperStrict 

Local Window:TGadget = CreateWindow("Launcher", 40, 40, 320, 240, ,WINDOW_TITLEBAR | WINDOW_RESIZABLE | WINDOW_ACCEPTFILES)

While True

	WaitEvent()

	Select EventID()
	
		Case EVENT_WINDOWCLOSE
			End
			
		Case EVENT_WINDOWACCEPT
			If EventSource() = Window
				Local files:String[] = (EventExtra().ToString()).Split("~n")
				For Local file:String = EachIn files
					Print "Filax Ficher: ~q"+file+"~q"
				Next
			    'Useful code here
			EndIf
						
	End Select
	
Wend

End

;)


SebHoll(Posted 2007) [#3]
As fredborg said, although I thought I'd mention you don't need to create a variable for the separate array of files if you are just looping through them... If I remember correctly, the (EventExtra().ToString()).Split("~n") will only be evaluated once for the loop, so will be just as fast. I.e.

SuperStrict 

Local Window:TGadget = CreateWindow("Launcher", 40, 40, 320, 240, ,WINDOW_TITLEBAR | WINDOW_RESIZABLE | WINDOW_ACCEPTFILES)

Repeat

	Select WaitEvent()
	
		Case EVENT_WINDOWCLOSE, EVENT_APPTERMINATE;End
			
		Case EVENT_WINDOWACCEPT
		
			If EventSource() = Window Then
				
				For Local strFile$ = EachIn (EventExtra().ToString()).Split("~n")
					Print "Filax Ficher: ~q" + strFile + "~q"
				Next
			    
			EndIf
						
	End Select
	
Forever



Filax(Posted 2007) [#4]
Many thanks :)