Recent

Author Topic: TCanvas width and height property  (Read 12358 times)

Ignace

  • New member
  • *
  • Posts: 8
TCanvas width and height property
« on: May 16, 2007, 10:27:06 pm »
TCanvas in Lazarus has width and Height property while TCanvas in Delphi does not. TCanvas should not have width and height property.

When I have following code in a form with a TPaintBox on it, Lazarus crashes while Delphi works:


with Paintbox1.Canvas.Pen do
    with Paintbox1.canvas do
    begin
      width := 2;
      moveto(10,10);
      lineto(40,200);
    end;

Lazarus thinks width refers to the canvas.

I encountered a similar problem in real life when translating a delphi component to lazarus. It gave me weird results where a line was drawn with a linewidth equal to the canvas width instead of the pen width.

Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
RE: TCanvas width and height property
« Reply #1 on: May 16, 2007, 10:49:31 pm »
File a delphi bug report for missing properties.

In the mean time, don't use with.

Ignace

  • New member
  • *
  • Posts: 8
RE: TCanvas width and height property
« Reply #2 on: May 16, 2007, 10:52:37 pm »
OK, I just found the bug reporting section.
By the way, this is not a missing property, that property SHOULD be missing.

Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
RE: TCanvas width and height property
« Reply #3 on: May 16, 2007, 10:55:19 pm »
No, absolutely not. It is a Delphi bug that it hasn't the property. You should report it with CodeGear.

Ignace

  • New member
  • *
  • Posts: 8
RE: TCanvas width and height property
« Reply #4 on: May 16, 2007, 11:00:05 pm »
Yeah right :)
Lazarus is the one who is cloning the other, remember :)
I think Lazarus should be consistent with Delphi

Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
RE: TCanvas width and height property
« Reply #5 on: May 16, 2007, 11:02:53 pm »
No, if it can improve for example by adding extra properties, it will.

If you think Lazarus is a clone, that you are in a for a disapointment.

Next you will be complaining about the fact that a form has a text property, which breaks your Delphi code.

nanni

  • Newbie
  • Posts: 3
  • 1 year old:-)
    • TMySoft
Re: TCanvas width and height property
« Reply #6 on: December 18, 2021, 05:42:00 pm »
with ACanvas do begin
  w:= cliprect.Right -cliprect.Left;
  h:= cliprect.Bottom -cliprect.Top;
  ..

 

TinyPortal © 2005-2018