[Lazarus] Lazarus Equivalent of GetCharABCWidths API call

Dominique Louis dominique at savagesoftware.com.au
Sun Feb 17 22:31:37 CET 2008


Hi Philip,
   So am I right in saying that ABCStructs is available as a native lcl 
struct?

I mainly need this for Mac OS X for now, but will need it for Linux 
further down the line.

So use TCarbonWidgetSet what unit do I need to include and do you have a 
small example of using GetCharABCWidths in Mac OS X?

Thanks,


Dominique.

Hess, Philip J wrote:
> Hi Dominique,
> 
> The portable equivalent is in LclIntf, but it's not implemented in all widgetsets. Last fall I was playing around with this function for Carbon. Not sure where I left it but here's what I came up with. Maybe you could implement it for non-win32 widgetsets.
> 
> Thanks.
> 
> function TCarbonWidgetSet.GetCharABCWidths(DC: HDC; p2, p3: UINT;
>   const ABCStructs): Boolean;
> type
>   TABCArray = array[0..255] of TABC;
>   PABCArray = ^TABCArray;
> var
>   ABCPtr   : PABCArray;
>   CharNum  : Integer;
>   CharStr  : string;
>   CharSize : TSize;
> begin
>   ABCPtr := PABCArray(@ABCStructs);
>   for CharNum := p2 to p3 do
>     begin
>     CharStr := Chr(CharNum);
>     GetTextExtentPoint(DC, PChar(CharStr), 1, CharSize);
>     ABCPtr^[CharNum-p2].abcA := 0;
>     ABCPtr^[CharNum-p2].abcB := CharSize.cx;
>     ABCPtr^[CharNum-p2].abcC := 0;
>     end;
>   Result := True;
> end;
> 
> 
> -----Original Message-----
> From: lazarus-bounces at lazarus.freepascal.org on behalf of Dominique Louis
> Sent: Sun 2/17/2008 1:40 PM
> To: General mailing list
> Subject: [Lazarus] Lazarus Equivalent of GetCharABCWidths API call
>  
> Hi All,
>    What is the portable equivalent of the Win32 GetCharABCWidths API call?
> 
> Would Canvas.TextWidth be enough?
> 
> Thanks,
> 
> 
> Dominique.





More information about the Lazarus mailing list