[Gambas-user] Best control for a game

Werner wdahn at ...1000...
Fri Sep 5 06:35:02 CEST 2008


Tomas Eroles i Forner wrote:
> Hi again
> Well, I've made some research in DrawingArea.
> I've been reading the documentation on the wiki, and, if I understand
> it, for drawing I have to draw into a DrawingArea enclosing all draw
> commands in a Draw.Begin(DrawingArea)...Draw.End group of code.
>
> It seems to work, but, I see that you can start drawing if you put a
> command button, or a menu or something like this, but it does not work
> in a Form_Open event.
>
> Is it like this?
>
> Thanks
>   
It is meant to be used somewhat differently.
You can put all your drawing commands in a

Draw.Begin(DrawingArea)...Draw.End group of code.

However, it is much more practical to use the drawing area's draw event
http://gambasdoc.org/help/comp/gb.qt/drawingarea/.draw

because it will also deal with needs to redraw that come from outside the application i.e.other applications' windows that were partially overlapping. Have a look at the "Analog Watch" example.

So your Draw event would look like this:

PUBLIC SUB dwgScrabble_Draw()	'don't use BEGIN and END, it is already done
	...
	...
END

Also, do not use WAIT statements in here if there is any slight chance 
that something elsewhere wanted to be drawn. I learned this the hard way 
:-D

Regards
Werner





More information about the User mailing list