List Info

Thread: RE: Working with ExtTextOut




RE: Working with ExtTextOut
country flaguser name
United States
2008-03-19 09:52:45

Hi Rob!

Your observation combined with Theo's code cleanup fixed the problem.

Here is the final code for those who may need to do this in the future:

// *** This procedure Centers all cells in the grid ****

procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow:
Integer;
Rect: TRect; State: TGridDrawState);
var
Text : string;
Begin
Text := StringGrid1.Cells[Acol,ARow];
ExtTextOut(StringGrid1.Canvas.Handle,
Rect.Left + (Rect.Right - Rect.Left -
StringGrid1.Canvas.TextWidth(Text)) div 2,
Rect.Top + 2,
ETO_OPAQUE or ETO_CLIPPED,
Rect,
PChar(Text),
Length(Text),
nil);
end;

//************** End of Code ***********

Thanks for your input, Rob

Tom Nesler
Live long!... Code Well!... and Prosper!... V

-----Original Message-----
From: delphi-en%40yahoogroups.com">delphi-enyahoogroups.com [mailto: delphi-en%40yahoogroups.com">delphi-enyahoogroups.com] On
Behalf Of Rob Kennedy
Sent: Tuesday, March 18, 2008 8:07 PM
To: delphi-en%40yahoogroups.com">delphi-enyahoogroups.com
Subject: Re: [delphi-en] Working with ExtTextOut

....
> ExtTextOut(Handle,
> // HDC
> Rect.Left + (Rect.Right - Rect.Left -
> TextWidth(Text)) div 2, // X Position
> Top + DY,

Do you mean Rect.Top?

__._,_.___
.

__,_._,___
RE: Working with ExtTextOut
country flaguser name
United States
2008-03-19 10:44:53

You should use Sender instead of StringGrid1. That's what it's for.

"Nesler, Thomas J" < tnesler%40amfam.com">tnesleramfam.com> wrote: Hi Rob!

Your observation combined with Theo's code cleanup fixed the problem.

Here is the final code for those who may need to do this in the future:

// *** This procedure Centers all cells in the grid ****

procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow:
Integer;
Rect: TRect; State: TGridDrawState);
var
Text : string;
Begin
Text := StringGrid1.Cells[Acol,ARow];
ExtTextOut(StringGrid1.Canvas.Handle,
Rect.Left + (Rect.Right - Rect.Left -
StringGrid1.Canvas.TextWidth(Text)) div 2,
Rect.Top + 2,
ETO_OPAQUE or ETO_CLIPPED,
Rect,
PChar(Text),
Length(Text),
nil);
end;

//************** End of Code ***********

Thanks for your input, Rob

Tom Nesler
Live long!... Code Well!... and Prosper!... V

-----Original Message-----
From: delphi-en%40yahoogroups.com">delphi-enyahoogroups.com [mailto: delphi-en%40yahoogroups.com">delphi-enyahoogroups.com] On
Behalf Of Rob Kennedy
Sent: Tuesday, March 18, 2008 8:07 PM
To: delphi-en%40yahoogroups.com">delphi-enyahoogroups.com
Subject: Re: [delphi-en] Working with ExtTextOut

....
> ExtTextOut(Handle,
> // HDC
> Rect.Left + (Rect.Right - Rect.Left -
> TextWidth(Text)) div 2, // X Position
> Top + DY,

Do you mean Rect.Top?





---------------------------------
Never miss a thing. Make Yahoo your homepage.

[Non-text portions of this message have been removed]

__._,_.___
.

__,_._,___
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )