Child Windows (MaxGui)

BlitzMax Forums/BlitzMax Programming/Child Windows (MaxGui)

Gavin Beard(Posted 2006) [#1]
HI all,

I've created a popup window within another window (MDI style) but i want it so focus is fixed on the new window and the user cant go back to the main window until closing the front window, i thought maybe flag WINDOW_CHILD may do it but no :(

n e ideas?


Diablo(Posted 2006) [#2]
cant u just disable the other window and then when the child window is closed just enable it again.


Scott Shaver(Posted 2006) [#3]
some variation of this might work:

http://www.blitzbasic.com/Community/posts.php?topic=56501


Gavin Beard(Posted 2006) [#4]
Perfect Mr Shaver thanks :D


Scott Shaver(Posted 2006) [#5]
note that you should disable any menus in other windows because they will still respond.


Gavin Beard(Posted 2006) [#6]
am i right in thinking that bmax ide was made with maxgui? if so i wonder how they did it with the syncmod dialog?


Diablo(Posted 2006) [#7]
you get the source to bmax ide with blitzmaxGUI so why not look for yourself.


Gavin Beard(Posted 2006) [#8]
i did?? wow...lol


Diablo(Posted 2006) [#9]
as far as i make out its all done with disable gadget
Type tapp
	
	Field mwindow:tgadget
	Field pwindow:tgadget
	
	Field sbutton:Tgadget
	
	Method New()
	
		mwindow = CreateWindow("main window", 0, 0, ClientWidth(Desktop()), ClientHeight(Desktop()))
		MaximizeWindow mwindow
		
		pwindow = CreateWindow("Popup", 100, 100, 200, 200, Null, 65)
		HideGadget pwindow
		
		sbutton = CreateButton("popup", 10, 10, 100, 20, mwindow)
		
	End Method
	
End Type

Global mapp:tapp = New tapp

While True

	WaitEvent
	
	Select EventID()
	
		Case event_windowclose
		
			Select EventSource()
				
				Case mapp.mwindow
					End
				
				Case mapp.pwindow
					EnableGadget mapp.mwindow
					HideGadget mapp.pwindow
					
			End Select
			
		Case event_gadgetaction
			
			If EventSource() = mapp.sbutton Then 
				DisableGadget(mapp.mwindow)
				ShowGadget(mapp.pwindow)
			EndIf
			
	End Select
	

Wend



Gavin Beard(Posted 2006) [#10]
OK....been playin with code from another post and i can make a second window appear thats always in front. however it requires me to click the menu option twice to get the menu to appear in the first place:


Type TNWorderWin

Field Window:TGadget = CreateWindow("new window",0,0,640,480,Null,WINDOW_TITLEBAR|WINDOW_STATUS|WINDOW_MENU)
Field RegWin:TGadget
Field FileMnu:TGadget = CreateMenu ("&File",0,WindowMenu(window))
Field HelpMnu:TGadget = CreateMenu ("&Help",0,WindowMenu(window))

Method New()
CreateMenu("&About",101,HelpMnu)
CreateMenu("&Register",102,FileMnu,KEY_R,MODIFIER_COMMAND)
CreateMenu("&Exit",103,FileMnu,KEY_E,MODIFIER_COMMAND)
AddHook EmitEventHook,eventhook,Self
UpdateWindowMenu Window
EndMethod

Function eventhook:Object(id:Int,data:Object,context:Object)
If TNWorderWin(context) Then TNWorderWin(context).OnEvent TEvent(data)
Return data
EndFunction

Method Delete()
RemoveHook EmitEventHook,eventhook
FreeGadget(window)
EndMethod

Method OnEvent(event:TEvent)
Select event.id
Case EVENT_WINDOWCLOSE
Select Event.Source
Case window
FreeGadget(window)
End
Case RegWin
FreeGadget (RegWin)
End Select

Case EVENT_GADGETACTION
Select Event.Source

EndSelect
Case EVENT_GADGETPAINT
Select Event.Source

EndSelect
Case EVENT_MENUACTION
Select EventData()
Case 103
End
Case 101
RegWin = CreateWindow("Register",0,0,320,240,Window,WINDOW_TITLEBAR)
ActivateGadget RegWin
EndSelect

EndSelect
EndMethod

EndType


Global App:TNWorderWin= New TNWorderWin

While True
WaitEvent()
Wend


Diablo(Posted 2006) [#11]


couldnt figure out what yo wanted at first but is this it. cant think way you version dont work.

EDIT better version IMO



Gavin Beard(Posted 2006) [#12]
yeah, thats alot better :) Thank Diablo, not sure why mine went pear shaped :)