Article View: comp.windows.ms.programmer
Article #3049Problem with the WSPrintF function
From: F0O
Date: Wed, 05 Jun 1991 12:49
Date: Wed, 05 Jun 1991 12:49
42 lines
1734 bytes
1734 bytes
Hi netters!
I'm new to Windows programming and I was trying to modify the
STEP3.PAS example program that comes with TPW. I was changing the
WMLButtonDown method. The original routine looks like this:
Procedure TMyWindow.WMLButtonDown(Var Msg:TMessage);
VAR
DC: HDC;
S: array[0..9] of char;
BEGIN
WVSPrintF(S, '(%d,%d)', Msg.LParam);
DC := GetDC(HWindow);
TextOut(DC, Msg.LParamLo, Msg.LParamHi, S, StrLen(S));
ReleaseDC(HWindow, DC);
END;
This of course works fine, but I modified the code in the following
way so I could print some text instead of a number:
Procedure TMyWindow.WMLButtonDown(Var TextString: PChar);
VAR
DC: HDC;
S: PChar;
BEGIN
WVSPrintF(S, '%s', TextString);
DC := GetDC(HWindow);
TextOut(DC, Msg.LParamLo, Msg.LParamHi, S, StrLen(S));
ReleaseDC(HWindow, DC);
END;
When Windows hits the WVSPrintF statement, I get a UAE. By running
in the debugger, the UAE is reported as exception code 13, a memory
addressing error.
The problem must be that I'm not using PChar correctly, although
the on-line help states all parameters of WVSPrintF are of type PChar
and the manual shows examples of where you can put a text string into
a variable of type PChar.
If someone can tell me what I'm doing wrong, I'd greatly appreciate
it!
[Tim]
Technical Details
Message-ID:
<91156.084930F0O@psuvm.psu.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!psuvax1!psuvm!f0oShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!psuvax1!psuvm!f0o Organization: Penn State University Date: Wednesday, 5 Jun 1991 08:49:30 EDT From: <F0O@psuvm.psu.edu> Message-ID: <91156.084930F0O@psuvm.psu.edu> Newsgroups: comp.windows.ms.programmer Subject: Problem with the WSPrintF function