You should use Sender instead of StringGrid1. That's what it's for.
"Nesler, Thomas J" < tnesler%40amfam.com">tnesler
amfam.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-en
yahoogroups.com [mailto: delphi-en%40yahoogroups.com">delphi-en
yahoogroups.com] On
Behalf Of Rob Kennedy
Sent: Tuesday, March 18, 2008 8:07 PM
To: delphi-en%40yahoogroups.com">delphi-en
yahoogroups.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]
.