ClientWidth help from other OS's

BlitzMax Forums/BlitzMax GUI Programming/ClientWidth help from other OS's

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Here is a short example of a scrollbar. Normally you want to have a hook function for the movement to have an immediate effect.

SuperStrict
Import MaxGui.Drivers


Global PanelAsWindow:TGadget
Global PanelToScroll:TGadget
'End of Header File


Local Window1:TGadget = CreateWindow:TGadget("Window1",87,108,335,262,Null,WINDOW_TITLEBAR|WINDOW_RESIZABLE |WINDOW_STATUS )
	' a panel used as window we look through to to see a part of the bigger scroll-area
	PanelAsWindow:TGadget = CreatePanel:TGadget(0,0,299,167,Window1:TGadget,Null,"Panel1")
		SetGadgetLayout( PanelAsWindow:TGadget,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED )

	'the panel we want to scroll
	PanelToScroll:TGadget = CreatePanel:TGadget(0,0,299,278,PanelAsWindow:TGadget,Null,"Panel2")
		SetGadgetLayout( PanelToScroll:TGadget,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED )

	'some gagdets on top to scroll, not important
	Local TextField1:TGadget = CreateTextField:TGadget(93,36,80,18,PanelToScroll:TGadget,Null)
		SetGadgetText( TextField1:TGadget,"TextField1")
	Local TextArea1:TGadget = CreateTextArea:TGadget(12,173,275,95,PanelToScroll:TGadget,Null)
		SetTextAreaText( TextArea1:TGadget , "TextArea1" )
	Local Label1:TGadget = CreateLabel:TGadget("Label1",12,95,80,16,PanelToScroll:TGadget,LABEL_SUNKENFRAME)
	Local ProgBar1:TGadget = CreateProgBar:TGadget(207,88,80,23,PanelToScroll:TGadget,Null)
		UpdateProgBar( ProgBar1:TGadget,0.200000003 )
	'a button outside the scrollarea		
	Local Ok1:TGadget = CreateButton:TGadget("Ok1",224,178,75,23,Window1:TGadget,BUTTON_OK)
	


	'set the scrollbar
	Local SB1:TGadget = CreateSlider:TGadget(303,0,23,167,Window1:TGadget,SLIDER_VERTICAL | SLIDER_SCROLLBAR )
				SetSliderRange( SB1:TGadget,1 ,100 )
				SetSliderRange( SB1:TGadget,GadgetHeight(PanelAsWindow),GadgetHeight(PanelToScroll))


Repeat
	WaitEvent()
	Select EventID()
		Case EVENT_WINDOWCLOSE
			Select EventSource()
				Case Window1	Window1_WC( Window1:TGadget )
			End Select

		Case EVENT_GADGETACTION
			Select EventSource()
				Case SB1	SB1_GA( SB1:TGadget , EventData() )
				Case Ok1	Ok1_GA( Ok1:TGadget )
			End Select

	End Select
Forever

Function Window1_WC( Window:TGadget )
	DebugLog "Window Window1 wants to be closed"
'	HideGadget( Window:TGadget )

	End
End Function

Function SB1_GA( Slider:TGadget , Number:Int )
	DebugLog "Slider SB1 changed to " + Number
		SetGadgetShape( PanelToScroll:TGadget,GadgetX(PanelToScroll),GadgetY(PanelAsWindow)-Number,GadgetWidth(PanelToScroll),GadgetHeight(PanelToScroll) )
	
End Function

Function Ok1_GA( Button:TGadget )
	DebugLog "Button Ok1 was pressed"
	
End Function