Lazarus
Programming => Graphics and Multimedia => Graphics => Topic started by: WalterK on April 15, 2011, 05:03:00 pm
-
I'm using version 0.9.30 on my PowerPC Mac running OS 10.5.8...
I''m trying to draw some lines in a TPanel (GraphPanel). The below code (boiled down) has no visible output on my Mac, but does draw a line on my Windows laptop (Vista).
maxY := GraphPanel.Height;
maxX := GraphPanel.Width;
GraphPanel.Canvas.Pen.Color:=clBlack;
GraphPanel.Canvas.Pen.Width:=4;
GraphPanel.Canvas.Line(0,0,maxx,maxy);
GraphPanel.Invalidate;
Can someone tell me what I'm doing wrong?
TIA.
-
Maybe it's because a TPanel isn't supposed to be used as a drawing surface.
For example it doesn't have an (accessible) OnPaint method.
Maybe it works if you manually set the OnPaint method of TPanel and do all painting in there.
-
I do know there is indeed a difference in how (or when) Windows and Mac update the screen. I haven't been able to exactly pinpoint what that difference is.
Your code does not say where it is actually invoked (in some onxxxxxx event I gather), so it is hard to tell what heppens.
Incidentally ... a TPaintbox won't work either?
-
Or ... a TImage.
-
OK. It's working now...
I used a TPanel because it has a Canvas and I didn't know any better. I was drawing the lines upon a button click. Apparently this is major-ignorant.
I changed to use a TPaintBox and put the line drawing code inside an OnPaint routine and it works. (I'll suspect this will work under Windows also.)
Thanks.
-
If you call Invalidate after you draw, it erases everything.