MaxGUI on an existing hWnd.

BlitzMax Forums/MaxGUI Module/MaxGUI on an existing hWnd.

itsdanreed(Posted 2008) [#1]
Well, after taking a peek at maxgui.win32maxguiex,
I made this.
Strict

Import maxgui.drivers
Import maxgui.win32maxguiex
Import pub.win32

Graphics(640, 480)

Global Window:TGadget = CreateWindowFromHwnd(GetActiveWindow( ), WINDOW_MENU|WINDOW_STATUS)
Global File:TGadget = CreateMenu("&File", 0, Window.GetMenu( ))
CreateMenu("E&xit", 100, File)
UpdateWindowMenu( Window )

Repeat
	PollEvent( )
	
	Select EventID( )
		Case EVENT_MENUACTION
			Select EventData()
			Case 100
				End
			End Select
	End Select
	Cls( )
	
	Flip( )
Until (KeyHit(KEY_ESCAPE))

Function CreateWindowFromHwnd:TGadget(hWnd:Int, Style:Int = 15)
	' Local objects:
	Local OldStyle:Int
	Local NewStyle:Int
	Local Client:Int
	Local Window:TWindowsWindow = New TWindowsWindow
	Local _wstrEmpty:Byte Ptr
	
	If (Style & WINDOW_MENU)
		Window._hmenu = CreateMenu_( )
		AppendMenuW(Window._hmenu, MF_STRING, Null, _wstrEmpty)	
	EndIf
	
	Window.Register(GADGET_WINDOW, hWnd, Client, False)
	
	Return( Window )
End Function


Using this code, I was able to use a MaxGUI menu window a Max2D window. and of course, due to the nature of this code, it's Win32 flavor only.


itsdanreed(Posted 2008) [#2]
It works with Blitz3D, but not as well as I'd like, the window needs to be subclassed and I'm not sure how to do that in blitzmax. I need to subclass aswell to acheive buttons, ect.