Skip to content

CreateCanvas

Narta Xaymar Dirks edited this page Oct 28, 2026 · 5 revisions
BlitzPlus

CreateCanvas

CreateCanvas:Int32 x:Int32, y:Int32, width:Int32, height:Int32, group:Int32, style:Int32=0
Parameter Mode Type Default Description
x In Int32 required Horizontal position inside the group.
y In Int32 required Vertical position inside the group.
width In Int32 required Width of the canvas.
height In Int32 required Height of the canvas.
group In Int32 required Window, panel or tabber that holds it.
style In Int32 0 0 lets the canvas follow the size of its group when SetGadgetLayout says so, 65536 keeps it as it is. Defaults to 0.

Returns: A handle for the canvas.

Description

Makes a rectangular area in a window or panel that your program paints on itself, for animations, graphs or anything else the other gadgets cannot show. Canvases also tell you about the mouse: they send $203 when it moves over them and $205 and $206 when it enters or leaves, with the position in EventX and EventY, and they get keyboard events when they have the focus.

Draw with CanvasBuffer and FlipCanvas. A canvas can also be the group of other gadgets.

Differences

  • Canvases are drawn by the same renderer as the rest of the interface, so nothing needs DirectX.

Examples

Graphics 320, 240, 32, 2
win = CreateWindow("Spinner", 20, 20, 280, 190, Desktop(), 3)
cv  = CreateCanvas(10, 10, 250, 140, win)
frame = 0
Repeat
	SetBuffer CanvasBuffer(cv)
	ClsColor 0, 0, 0
	Cls
	Color 0, 255, 120
	a# = frame * 15
	Line 125, 70, 125 + Cos(a) * 55, 70 + Sin(a) * 55
	Oval 120, 65, 10, 10, 1
	FlipCanvas cv
	frame = frame + 1
	e = WaitEvent(100)
Until e = $803

Media

CreateCanvas

Related Commands

CanvasBuffer, DesktopBuffer, FlipCanvas

Home · Command Index



Differences
Language Features
BlitzBasic
Blitz3D
BlitzPlus

Clone this wiki locally