[futurebasic] Re: [FB] Text from resources

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : October 2001 : Group Archive : Group : All Groups

From: Alain Pastor <apastor@...>
Date: Wed, 31 Oct 2001 13:44:43 +0100
David Cottrell wrote:
> 
> Can someone tell me how to get text from a resource and put the styled
> text into a appearance compliant control?
> 
> eg I get the text handle with:
> 
> resHndl = FN GETRESOURCE(_"pG3t",gObjResID)
> 
> and set the controls with:
> 
> btnH = fn NewControl(windowPtr,gObjT,"", _zTrue, 0, 0, 0,
> _kControlStaticTextProc, 0 )
> err = fn SetControlData(btnH, 0, _kControlStaticTextTextTag, ????, ????)
> 
> but what goes in where the ???? are?
> 
> Also what about style data? Do I need to use:
> 
> _kControlStaticTextStyleTag ?
> 
> Am I having fun yet?
> 
> David
> 
> PS - looks like we lost our other stats programmer - darn...
> 

Perhaps, you will have to extract the info from the pG3t resource,
splitting the text data handle and style info handle. Then maybe
whether you would have to build a text edit record using TENew or
extract the existing TEHandle from the control with:
err = GetControlData(btnH ,_kControlEditTextPart,_kControlEditTextTEHandleTag,SIZEOF(handle),teH,actualSize)
then use
TESetText( [txtDataH], fn GetHandleSize( txtDataH ), teH )
and
SetStylHandle( stylH, teH)

I don't think you would need to set back the text edit record handle
in the control, but just in case:

err = fn SetControlData(btnH, 0, _kControlEditTextTEHandleTag,
sizeof(handle), teH)

A DrawOneControl(btnH) may be necessary to see the change or an
InvalRect to force an update event.

Of course, I have no idea if that would work.

If the above fails, you may consider another approach:
For static fields you can possibly use autoScrolling text box
controls without scrolling (maybe with a timing of 0 or an
outrageous delay), I think you can just pass the resID of the TEXT
resource to such kind of controls and if a styl resource exists it
is automatically used.
You can set the ResID like this (I believe)

err = fn SetControlData(btnH, 0, _ kControlScrollTextBoxContentsTag,
sizeof(int), ResID)

Hold on, it should work both with scrolling text boxes and standard
text boxes.

Again, I don't know if all this would work, and perhaps you have
already explored those possibilities, those are just ideas that come
to mind.
-- 

Cheers

Alain

-----------------------------------------------------
FB^3 in Europe:  http://euro.futurebasic.com/
FB II Pouch:     http://www.pixmix.com/FB/outils.html
-----------------------------------------------------