drag and drop files onto BMAX window

BlitzMax Forums/BlitzMax Programming/drag and drop files onto BMAX window

Boulderdash(Posted 2006) [#1]
Its like this (Please HELP!):

I have made an emulator in BlitzMAX and want to add a feature enabling the .bin (ROM data) to be Dragged and Dropped onto the window.

Oh and I dont have or want to use MAXgui

Im assuming that is it something to do with the HOOK command but the documentation is rather brief.


ozak(Posted 2006) [#2]
I'm not really sure it can be done without MaxGUI unless you want to fiddle with the windows message loop and ugly C based GDI code.
I do however yearn to be proved wrong :) Anyone?


Boulderdash(Posted 2006) [#3]
From BMAX documentation:

Event id: Event description
EVENT_WINDOWACCEPT Drag and Drop operation was attempted

This tells me yes it can be done, but documentations shit as.


Boulderdash(Posted 2006) [#4]
All I should need is an example of HOOKs in some source code.

I have never heard of a compiler with no documentation on how to use some of the commands.

makes it so hard, but its still a great improvement on Blitz3d.


Byteemoz(Posted 2006) [#5]
Only MaxGUI windows created with the WINDOW_ACCEPTFILES flag set produce EVENT_WINDOWACCEPT-events.
I think the window created using Graphics(...) doesn't catch any drag-and-drop events...
-- Byteemoz


Dreamora(Posted 2006) [#6]
Right
You would need to modify the original source and add the needed flag when creating the window, because there is no intelligent reason a graphics context should check for file drop ... thats a "gui thing" not a 3d context thing


Boulderdash(Posted 2006) [#7]
Choice, Maybe max gui can do it, It would be cool if my emulator could be inside another window, this first window could be the ROMs folder and you drag the data files across to the emulator window to load them.


Boulderdash(Posted 2006) [#8]
I wonder why the documentation mentions Drag and Drop Hooks if it is not a feature of blitzMAX

perhaps if there was some examples!


impixi(Posted 2006) [#9]
The problem is the main BlitzMax window created at runtime is not set to handle drag and drop events. You would need to modify the BlitzMax source code to enable this.

You can, however, drag a file onto your program's .exe (or a shortcut to it) and utilise AppArgs to read the dragged item's name:


SuperStrict

Graphics 640,480,0

For Local i:Int = 0 To (AppArgs.length - 1)
	Print AppArgs[i]
Next

While Not KeyHit( KEY_ESCAPE )

Wend

End



Your users could launch your emulator loading a single ROM in such a way.

Alternatively you could reconsider purchasing the MaxGUI module. Drag and drop is very simple:


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
			    Print EventExtra().ToString()
			    'Useful code here
			EndIf
						
	End Select
	
Wend

End




Boulderdash(Posted 2006) [#10]
interesting and thanks.

How much bigger would the .exe be, its only 224K at moment, I wouldnt bother if it ends up like B3D and 1.5mb, waste of time at that size.


kfprimm(Posted 2006) [#11]
a blank exe with just BRL.D3D7Max2D set as the framework,
debug - 773 KB
release - 151 KB

with brl.win32maxgui also imported,
debug - 1.15 MB
release - 461 KB

you should definitely get maxgui.


Boulderdash(Posted 2006) [#12]
Im im im... downloading it now!


Boulderdash(Posted 2006) [#13]
Nah I think that I will alter the BMAX source code instead of making the executable more than double the size just for that function.

Also because im going to have downloads for MAC and LYNX and then different emulators based on the same source, the extra storage space required isnt worth it.


Boulderdash(Posted 2006) [#14]
I found this in the code section, perhaps a variant of this could be used to add drag and drop? I didnt write it so i dont know.

Import BRL.EventQueue
Import BRL.Event

Extern "win32" ' Crazy WinAPI stuff
Function GetActiveWindow%()
Function IsZoomed%(hwnd%)
End Extern

Graphics 800,600,0,60

Global hWnd% = GetActiveWindow() ' Save current Window handle
' Init Buttons
enableMinimize( hwnd% )
enableMaximize( hwnd% )





main ...

... loop
end

Function enableMaximize(hWnd:Long)
' Adds the Maximize Button "[]"
Local tmp:Int = GetWindowLongA( hWnd, GWL_STYLE )
tmp = tmp | WS_MAXIMIZEBOX
SetWindowLongA( hWnd, GWL_STYLE, tmp )
DrawMenuBar( hWnd )
End Function

Function enableMinimize(hWnd:Long)
' Adds the Minimize Button "_"
Local tmp:Long = GetWindowLongA( hWnd, GWL_STYLE )
tmp = tmp | WS_MINIMIZEBOX
SetWindowLongA( hWnd, GWL_STYLE, tmp )
DrawMenuBar( hWnd )
End Function