Home
Products
Community
Manuals
Contact
Login or Signup

BlitzPlus Docs -> GUI - Category -> Gadgets -> SetGadgetShape

SetGadgetShape gadget,x,y,width,height

Parameters:

gadget - A gadget handle
x,y,width,height - New gadget shape

Description:

SetGadgetShape allows you to change the position and size of a gadget.

NB. only use SetGadgetShape on a canvas if you don't mind the distortion/stretching of the actual canvas pixels.

See also: GadgetX, GadgetY, GadgetWidth, GadgetHeight, SetGadgetLayout, SetGadgetFont, SetGadgetText.

Example:

; Create a window, and button
win = CreateWindow("Play The Click Me Game",100,100,200,200,0,57)
button = CreateButton("Click Me!",50,50,100,100,win)

; Set everything up to start our little game
SetStatusText win,"Click the button to start the game!"
clicks = 0

; A small event loop
Repeat

	; Wait for events
	id = WaitEvent()
	Select id
	
		; Exit on window close
		Case $803 : Exit 
		
		; Button clicked
		Case $401
			; move the button
			SetGadgetShape button,Rnd(150),Rnd(180),50+Rnd(50),20+Rnd(80)
			; update game information
			If clicks=0 Then time = MilliSecs()
			clicks = clicks + 1
			SetStatusText win, clicks + " clicks in " + (MilliSecs()-time)/1000.0 + " seconds"
			
	End Select
	
Forever

End ; bye! 

Comments

TAS(Posted 1+ years ago)
Strange visual effects will occur if w,h are changed on a canvas gadget, use freegadget, creatgadget instead to resize a canvas


Stamm(Posted 1+ years ago)
What about simply flipping the canvas afterwards?


TAS(Posted 1+ years ago)
Nope, canvas updates will be squashed or stretch too. The Freegadget approach causes a lot of screen flicker as the window/canvas is resized. The correct approach is to make the canvas the maximum size needed or possible (due to screen resolution) on start-up, lock the top and right edges and then only change x,y due to a resize event and only if x or y is non zero.


BlitzPlus Manual Forum

Blitz3D Equivalent Command