Thanks, I got it working with the following

r:= RECT(0, 0, ClientWidth, 0);
DrawText(Canvas.Handle, PChar(Caption), Length(Caption), r, DT_CALCRECT or 
DT_LEFT or DT_WORDBREAK);
r:= RECT(5, (Height - 5) div 2 - (r.Bottom - 5) div 2, Width - 5, Height - 
5);

It's result is not as good as my algorithm but it's so close that I'm not 
going to care lol
A lot of my code is "why do that when there's a easier way?" Simply cuz I'm 
ignorant =P

----- Original Message ----- 
From: "Mark Bracey" <[EMAIL PROTECTED]>
To: "Delphi-Talk Discussion List" <[email protected]>
Sent: Saturday, December 17, 2005 5:00 PM
Subject: RE: tool tip example and caption help


> The following routine is one I use in an OwnerDraw Listbox
>
> I set the Rect to 0,0,0,0 and then set the Width (R.Right) that I want.
>
> I call DrawText with DT_CALCRECT param and the result gives me the Height
> that I want returned in the TRECT (R) as the R.Bottom value.
>
>
> procedure TfrmRDISErrors.ListBox1MeasureItem(Control: TWinControl; Index:
> Integer; var Height: Integer);
> var R : TRect;
>    W : WideString;
> begin
> W  := ListBox1.Items[Index];
> R := Rect(0,0,0,0);
> R.Right := ListBox1.ClientWidth;
> DrawTextW(ListBox1.Canvas.Handle , PWideChar(W),Length(W), R, DT_CALCRECT
> or DT_LEFT or DT_WORDBREAK);
> Height := R.Bottom + 1;
> end;
>
> Maybe you aren't using it right?
>
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Behalf Of Richard R
> Sent: Saturday, December 17, 2005 5:50 PM
> To: Delphi-Talk Discussion List
> Subject: Re: tool tip example and caption help
>
>
> DT_CALCRECT just increased the width and shorted the height of the rect. 
> So
> it didnt help even with the other flags. Do you have an example?
>
> ----- Original Message -----
> From: "Mark Bracey" <[EMAIL PROTECTED]>
> To: "Delphi-Talk Discussion List" <[email protected]>
> Sent: Saturday, December 17, 2005 4:32 PM
> Subject: RE: tool tip example and caption help
>
>
>> It's not difficult.  See my post re: DT_CALCRECT
>>
>>
>>
>> -----Original Message-----
>> From: [EMAIL PROTECTED]
>> [mailto:[EMAIL PROTECTED] Behalf Of Richard R
>> Sent: Saturday, December 17, 2005 5:28 PM
>> To: Delphi-Talk Discussion List
>> Subject: Re: tool tip example and caption help
>>
>>
>>
>> __________________________________________________
>> Delphi-Talk mailing list -> [email protected]
>> http://www.elists.org/mailman/listinfo/delphi-talk
>>
> __________________________________________________
> Delphi-Talk mailing list -> [email protected]
> http://www.elists.org/mailman/listinfo/delphi-talk
>
> __________________________________________________
> Delphi-Talk mailing list -> [email protected]
> http://www.elists.org/mailman/listinfo/delphi-talk
> 
__________________________________________________
Delphi-Talk mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi-talk

Reply via email to