#TEXT Resource Display
7 messages in this thread
How does one go about displaying text stored in a TEXT resource? Got any
sample Pascal code?
Thanks in advance,
Ron
> How does one go about displaying text stored in a TEXT resource?
> Got any sample Pascal code?
Something like this:
textH := GetResource( 'TEXT', resID );
HLock( textH );
SetRect( dispRect, 50, 50, 350, 150 );
TextBox( textH^, GetHandleSize( textH ), dispRect, teJustLeft );
HUnlock( textH );
ReleaseResource( textH );
Of course, this won't scroll or anything. If you want to scroll through text,
then you'll probably want to put the text from the resource into a TextEdit
record, add a few scroll bars, etc etc. That's about 100-500 lines of code (100
lines for uncommented spaghetti, 500 lines for nice modular reusable code).
Brian,
Thanks for your help.
>>>
Of course, this won't scroll or anything. If you want to scroll through text,
then you'll probably want to put the text from the resource into a TextEdit
record, add a few scroll bars, etc etc. That's about 100-500 lines of code (100
lines for uncommented spaghetti, 500 lines for nice modular reusable code).
<<<
That's really what I'm after. I'll settle for some uncommented spaghetti if
you've got some. I've got my own, but I obviously don't know what I'm doing.
I have a help screen I've written that contains a topic list and a scrolling
text area (which doesn't scroll yet). But I'm not doing a good job of
recovering memory for what I've already got … losing 200-500 bytes each time
I display new text.
Rgds,
Ron
> I have a help screen I've written that contains a topic list and
> a scrolling text area (which doesn't scroll yet).
If you don't mind reading C code (I think you requested Pascal) I posted code
for the same task, called Show_help. Look for SHHELP.SIT in the libs, probably
the C and Pascal Lib.
Thanks James.
I'll C if I can read it.
Ron
I don't have any uncommented spaghetti (I gave it up for Lent many years ago)!
If you can't find any example source code in the MacDev libraries, let me know
in a few days and I'll try to abstract some out. It's not that hard, really,
but there are a few twists to getting it right.
I neglected to mention that source code for the more complicated version is
available. There are any number of "Help" libraries, that implement a "Help"
function. At the heart of most of them is code that
gets text from a resource
puts it into a TextEdit record
lets you scroll around in it
Search the MacDev libraries on the keyword "help" and see what turns up. I seem
to recall one in particular that was called "ShowHelp".