DrawText(Form1.Canvas.Handle, PChar(s), Length(s), LRect, iFormat);
Neither one of these modify LRect...
What gives? It looks like I'm doing it right...
myRect := Result := Rect(0, 0, 0, 0);
// Then either of the following should work
DrawText(Self.Canvas.Handle, PChar(S), -1, myRect, iFormat);
DrawText(Self.Canvas.Handle, PChar(S), Length(S), myRect, iFormat);
Give that a try :)
Some of the Win32 and .net routines check if the rect already has
dimensions, as it will not increase already set parameters. Instead,
for example, if it was a fixed width Rect, it would try to increase the
height to contain the text and maintain the width passed.
Hope that helps.
Scott :)
>
> myRect := Result := Rect(0, 0, 0, 0);
>
<SNIP>
Thanks, that worked.
> iFormat := DT_CALCRECT or DT_EDITCONTROL or
> DT_WORDBREAK or DT_NOPREFIX;
> DrawTextEx(Form1.Canvas.Handle, PChar(S), Length(S), LRect,
> iFormat,
> nil );
>
> DrawText(Form1.Canvas.Handle, PChar(s), Length(s), LRect, iFormat);
>
> Neither one of these modify LRect...
You need to set Left and Top of the Rect to 0 and Right to the width of
the text box you intend to draw to. DrawText will the put the needed
height into Bottom.
BTW, what's the result of DrawText and, in case it's 0, what's the
returns GetLastError?
-Michael
You're very welcome :)
Also, try that with fixed left, and top parameters, and watch the other
two change to fit the text you pass. Then just play with the initially
set parameters, it will become pretty clear after a few funnily drawn
rects :D
Have a good weekend.
Scott :)