Thanks Theo for the quick response and the code sample!
Unfortunately My text does not appear in the cells at all
now...:-(
I had to add the Uint Options variable to your code to get
it to compile but I am guessing my problem is that the
canvas is not getting refreshed.
Any suggestions?
Tom Nesler
-----Original Message-----
From: delphi-en@yahoogroups.com
[mailto:delphi-en@yahoogroups.com] On Behalf Of Theodoros
Bebekis
Sent: Tuesday, March 18, 2008 2:35 PM
To: delphi-en@yahoogroups.com
Subject: Re: [delphi-en] Working with ExtTextOut
O/H Nesler, Thomas J έγραψε:
>
>
> Hello!
>
> I am trying to implement some code I got to center text
in a String Grid
> cell. The original code was way too complex for my work
so I simplified
> it but I am missing something with the ExtTextOut Win32
Function. Here
> is my code:
>
> procedure TForm1.StringGrid1DrawCell(Sender: TObject;
ACol, ARow:
> Integer;
> Rect: TRect; State: TGridDrawState);
> var
> DY: Integer;
> Text: string;
> S: array[0..255] of Char;
> Const ARect: = Rect; <--------Problem here
>
> Begin
> Rect := ARect;
> DY := 2;
> Text := StringGrid1.Cells[Acol,ARow];
> with StringGrid1.Canvas do
> Begin X
> ExtTextOut(Handle,
> // HDC
> Rect.Left + (Rect.Right - Rect.Left -
> TextWidth(Text)) div 2, // X Position
> Top + DY,
> // YPosition
> ETO_OPAQUE or ETO_CLIPPED,
> // Text output options
> ARect,
> // Constant TRect type
> StrPCopy(S, Text),
> // Pointer to String
> Length(Text),
> // Length of String
> nil);
> // Pointer to intercharacter spacing
> end;
> end;
>
> According to the help text, ARect needs to be a
constant. However I
> cannot format the Constant in the upper section.
>
> Can anyone help here?
>
> Thanks in advance!
>
> Tom Nesler
>
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol,
ARow:Integer; Rect: TRect; State: TGridDrawState);
var
DY : Integer;
Text : string;
Begin
DY := 2;
Text := StringGrid1.Cells[Acol,ARow];
ExtTextOut(StringGrid1.Canvas.Handle,
Rect.Left + (Rect.Right - Rect.Left -
TextWidth(Text)) div 2,
Top + DY,
Rect,
PChar(Text),
Length(Text),
nil);
end;
--
Regards
Theo
------------------------
Theo Bebekis
Thessaloniki, Greece
------------------------
Greek_Delphi_Prog : a Delphi Programming mailing list in
Greek at
http:
//groups.yahoo.com/group/Greek_Delphi_Prog
CSharpDotNetGreek : A C# and .Net mailing list in Greek
language at
http:
//groups.yahoo.com/group/CSharpDotNetGreek
atla_custom : a Unisoft Atlantis Customization mailing list
at
http://grou
ps.yahoo.com/group/atla_custom
------------------------
------------------------------------
-----------------------------------------------------
Home page: http://group
s.yahoo.com/group/delphi-en/
To unsubscribe: delphi-en-unsubscribe@yahoogroups.comYahoo!
Groups Links
------------------------------------
-----------------------------------------------------
Home page: http://group
s.yahoo.com/group/delphi-en/
To unsubscribe: delphi-en-unsubscribe@yahoogroups.comYahoo!
Groups Links
<*> To visit your group on the web, go to:
http://group
s.yahoo.com/group/delphi-en/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://g
roups.yahoo.com/group/delphi-en/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:delphi-en-digest@yahoogroups.com
mailto:delphi-en-fullfeatured@yahoogroups.com
<*> To unsubscribe from this group, send an email to:
delphi-en-unsubscribe@yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.c
om/info/terms/
|