Redrawing during window move/size?

BlitzMax Forums/BlitzMax Programming/Redrawing during window move/size?

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.

If I understood your problem right you could do it this way:

SuperStrict

Global Window:TGadget, Canvas:TGadget, Run:Byte=True, Sus:Byte=False

Window = CreateWindow("Test",100,100,300,300,Null)
Canvas = CreateCanvas(0,0,300,300,Window)
SetGadgetLayout Canvas, EDGE_RELATIVE, EDGE_ALIGNED, EDGE_RELATIVE, EDGE_ALIGNED

SetGraphics CanvasGraphics(Canvas)
SetClsColor 0,0,255

AddHook EmitEventHook, ResizeWindow


While Run
	
	If PollEvent()
		If EventID() = EVENT_WINDOWCLOSE
			Run=False
		ElseIf EventID() = EVENT_MOUSEDOWN
			Sus=True
			RequestFile("Load")
			Sus=False
		End If
	End If
	
	Draw()
	
Wend

Function Draw()
	SetGraphics CanvasGraphics(Canvas)
	
	Cls
	
	SetColor 255,0,0
	DrawRect 10,20,50,70
	
	SetColor 0,255,0
	DrawOval 50,40,80,90
	
	Flip
	
End Function

Function ResizeWindow:Object(id:Int,data:Object,context:Object)
	Local Event:TEvent = TEvent(data)
	If Event.id = EVENT_WINDOWSIZE Or Sus=True
		SetViewport 0, 0, ClientWidth(Canvas), ClientHeight(Canvas)
		Draw()
	End If
	
	Event=Null
	Return data
End Function


To get the file requester just click on the canvas.

I just added a Sus variable and also set the if statement in the hook function to run if Sus = True. If you set Sus to true before you open the requestor and set it to false afterwards it works. There might be a better way but this seems to work fine for me.