Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2008-09

Typechecking problem porting from D7

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Frank de Groot / Rent-a-Geek

Hi guys - after a decade using Delphi, I finally switched to FPC! I like it a lot, so far.
Porting some code, I am stuck with something that looks trivial, however, and I hoped someone here can help out?
(If this is the wrong place, sorry!)

The following code, compiled to a WIN64 target gives a compile time error: TeCanvas.pas(1479,62) Error: Incompatible type for arg no. 3: Got "tagLOGBRUSH", expected "LOGBRUSH":

var LBrush : TLogBrush;
ExtCreatePen( PS_COSMETIC or PS_ALTERNATE,1, LBrush,0,nil );

In LCLType, TLogbrush is defined as such:

  PLogBrush = ^TLogBrush;
  tagLOGBRUSH = record
    lbStyle: LongWord;
    lbColor: TColorRef;
    lbHatch: PtrInt;
  end;
  TLogBrush = tagLOGBRUSH;
  LOGBRUSH = tagLOGBRUSH;

In redef.inc, the function header is defined as ExtCreatePen(PenStyle, Width: DWORD; const Brush: TLogBrush; StyleCount: DWORD; Style: Pointer): HPEN; external 'gdi32' name 'ExtCreatePen';

Florian Klaempfl
to Frank de Groot / Rent-a-Geek
Hi guys - after a decade using Delphi, I finally switched to FPC! I like it a lot, so far.

Actually Lazarus ;)

Porting some code, I am stuck with something that looks trivial, however, and I hoped someone here can help out?

As far as I can see from the mail, you're using a windows api function with an lcl type (the lcl redefines a lot of windows types and provides some also on other OSes).

Just try:
var LBrush : Windows.TLogBrush;
ExtCreatePen( PS_COSMETIC or PS_ALTERNATE,1, LBrush,0,nil );
Show quoted text 29 lines
(If this is the wrong place, sorry!) The following code, compiled to a WIN64 target gives a compile time error: TeCanvas.pas(1479,62) Error: Incompatible type for arg no. 3: Got "tagLOGBRUSH", expected "LOGBRUSH": var LBrush : TLogBrush; ExtCreatePen( PS_COSMETIC or PS_ALTERNATE,1, LBrush,0,nil ); In LCLType, TLogbrush is defined as such: PLogBrush = ^TLogBrush; tagLOGBRUSH = record lbStyle: LongWord; lbColor: TColorRef; lbHatch: PtrInt; end; TLogBrush = tagLOGBRUSH; LOGBRUSH = tagLOGBRUSH; In redef.inc, the function header is defined as ExtCreatePen(PenStyle, Width: DWORD; const Brush: TLogBrush; StyleCount: DWORD; Style: Pointer): HPEN; external 'gdi32' name 'ExtCreatePen'; _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Frank de Groot / Rent-a-Geek
to Florian Klaempfl
Actually Lazarus ;)

I like both :-)
One of my ex-colleagues is still using Delphi and he was amazed when he saw what Lazarus can do.
And he was impressed by the fact that FPC had inlined functions as well..

Just try: var LBrush : Windows.TLogBrush;

Works like a charm :-)
Thanks.