Hi All,
I'm using CW5 (patched) on Win98 to develop my latest project. I've got a
version of the WinDrawChars() function to draw characters in the current
window that takes a RectangleType rather than an X&Y point. The routine can
handle left/center/right alignment and will truncate the string and append
an ellipsis character if it won't fit otherwise.
Here's the beginning of it:
00:void Dugas::WinDrawChars(const CharPtr inCharsP, Int inCharLen,
01: const RectangleType& inBounds,
02: JustificationType inJustification,
03: fontID inFont, bool inInverted)
04:{
05: FontID savedFont = ::FntSetFont(inFont);
06:
07: // Determine the length of text that will fit within the bounds.
08: Int theWidth = inBounds.extent.x;
09: SWord maxChars = SWord(inCharLen);
10: Boolean theCharsFit;
11: ::FntCharsInWidth (const_cast<CharPtr>(inCharsP),
12: &theWidth, &maxChars , &theCharsFit);
13: if (! theCharsFit)
14: {
15: theWidth = inBounds.extent.x
16: - ::FntCharWidth (static_cast<Char>(horizEllipsisChr));
17: maxChars = inCharLen;
18: ::FntCharsInWidth (const_cast<CharPtr> (inCharsP), &theWidth,
19: &maxChars , &theCharsFit);
20: }
...
I'm getting POSE errors trying to write to protected memory or something
like that so I started stepping thought the code and I think the problem is
in this section somewhere. Here's what I've found. This routing is first
being called in a custom table entry draw callback. It's drawing record
numbers right justified in the table items bounds:
Dugas::WinDrawChars("1.", 2, inBounds, rightAlign, stdFont, false);
Here's the hitch, when I set a breakpoint at line 11, maxChars is set to -1
and so is theWidth. I've tried moving the assignments out of the
declaration:
Int theWidth;
SWord maxChars;
theWidth = inBounds.extent.x;
maxChars = static_cast<SWord>(inCharLen);
No change. This is *really* strange and has be stopped dead in my tracks.
Any ideas what's up?
Oh, I've considered looking at the assembly generated by CW but I'm not well
versed in the 68k. I have done x86 and HC11 assembly work before. Can
someone point me to the requisite 68k references? Gracias.
-Paul
--
Paul Dugas, Computer Engineer mailto:[EMAIL PROTECTED]
Dugas Enterprises, LLC At The Ga. DOT http://pauld.dugas.com
1711 Indian Ridge Drive tel:404-624-7840 tel:770-516-4955
Woodstock, GA 30189-6856, USA fax:404-624-7842 fax:770-516-4841