Board index » delphi » Using Win API's TextOut Function

Using Win API's TextOut Function

Hi, if anyone can help I would be very grateful.

I am trying to emulate the Petzold 6 inch ruler example to sort out how to
create, display and print metafiles from Delphi.

The following code snippet is the closest I have been to success:
Procedure....
Var
   Pp: array{1..5} of Integer;
   S: String;
.
.

For I:= 1 to 5 do
Begin
   Pp[i]:=i;
   S:=IntToStr(Pp[i]p):
   TextOut(hdc, i * cx Div 6, cy Div2, @s,1);
End

Tracing through (with function key F7) shows that '@s' displays 1 though 5 but
when displayed the numbers appear like ANSI type funny characters.

I am using Delph5 with Update Pack.
I would greatly appreciate any suggestions to solve this quirky problem.

Rod Nicholls
RAN 1...@aol.com
Rod

 

Re:Using Win API's TextOut Function


"Rod Nicholls" <ran...@aol.com> skrev i en meddelelse
news:20000823011711.00715.00000656@ng-bh1.aol.com...

Quote
>    TextOut(hdc, i * cx Div 6, cy Div2, @s,1);

Close, but no cigar.
You have to give the address of the string of characters:
   TextOut(..., @s[1], ...);

Finn Tolderlund

Re:Using Win API's TextOut Function


Quote
In article <20000823011711.00715.00000...@ng-bh1.aol.com>, Rod Nicholls wrote:
> TextOut(hdc, i * cx Div 6, cy Div2, @s,1);

Use:
TextOut(hdc, i * cx Div 6, cy Div2, PChar(s), 1);

--
Wed, 23 Aug 2000 22:15 EDT
Jim O'Brien, UnitOOPS Software   unito...@remove-this-prefix.unitoops.com
Check out our OLE Drag and Drop Components at <http://www.unitoops.com/>
Components for Delphi 5 included *free* on the D5 Companion CD.
Browse examples online at <http://www.unitoops.com/uoole/examples/>

Re:Using Win API's TextOut Function


Thanks to Finn Tolderlund and Jim O'Brien, both suggestions work.

Many thanks for your help.

Rod Nicholls.
Rod

Other Threads