Board index » cppbuilder » Canvas->Polygon();

Canvas->Polygon();

Hello,

I want to use Canvas->Polygon(); at my Form.

At the example I found:

void __fastcall TForm1::PaintBox1Paint(TObject *Sender)
{
  POINT points[4];
  points[0] = Point(10,10);
  points[1] = Point(30,10);
  points[2] = Point(130,30);
  points[3] = Point(240,120);
  ((TPaintBox *)Sender)->Canvas->Brush->Color = clTeal;
  ((TPaintBox *)Sender)->Canvas->Polygon(points, 3);

Quote
}
I  wrote:

void __fastcall TForm1::PaintBox1Paint(TObject *Sender)
{
  POINT points[4];
  points[0] = Point(10,10);
  points[1] = Point(30,10);
  points[2] = Point(130,30);
  points[3] = Point(240,120);
  Canvas->Brush->Color = clRed;
  Canvas->Polygon(points, 3);        // line with error

Quote
}

I get Error Message:
E2034 Cannot convert 'tagPOINT *' to 'const TPoint *'.
E2343 Type mismatch in parameter 'Points' in call to '__fastcall
TCanvas::Polygon(const TPoint*,const int)'.

Why???

 

Re:Canvas->Polygon();


Borland wants a TPoint not a POINT....

try switching...

Quote
Martin Getrost <m...@braehler.com> wrote in message

news:3B0A5BE8.457AD659@braehler.com...
Quote
> Hello,

> I want to use Canvas->Polygon(); at my Form.

> At the example I found:

> void __fastcall TForm1::PaintBox1Paint(TObject *Sender)
> {
>   POINT points[4];
>   points[0] = Point(10,10);
>   points[1] = Point(30,10);
>   points[2] = Point(130,30);
>   points[3] = Point(240,120);
>   ((TPaintBox *)Sender)->Canvas->Brush->Color = clTeal;
>   ((TPaintBox *)Sender)->Canvas->Polygon(points, 3);
> }

> I  wrote:
> void __fastcall TForm1::PaintBox1Paint(TObject *Sender)
> {
>   POINT points[4];
>   points[0] = Point(10,10);
>   points[1] = Point(30,10);
>   points[2] = Point(130,30);
>   points[3] = Point(240,120);
>   Canvas->Brush->Color = clRed;
>   Canvas->Polygon(points, 3);        // line with error
> }

> I get Error Message:
> E2034 Cannot convert 'tagPOINT *' to 'const TPoint *'.
> E2343 Type mismatch in parameter 'Points' in call to '__fastcall
> TCanvas::Polygon(const TPoint*,const int)'.

> Why???

Re:Canvas->Polygon();


I just want to point out that TPoint and POINT are typedefs of the same
Win32 API structure, tagPOINT.  Most of the time, they are interchangable.
I think the only reason why it's not in this example is because of the
'const' requirement of Polygon's parameters.

Gambit

Quote
Rick Golden <GoldenR...@hotmail.com> wrote in message

news:3b0a77f4$1_2@dnews...
Quote
> Borland wants a TPoint not a POINT....

Other Threads