[futurebasic] Re: [FB] PG window building

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : July 2000 : Group Archive : Group : All Groups

From: David Cottrell <David.Cottrell@...>
Date: Tue, 11 Jul 2000 11:54:52 +1000
> >'   try this instead, it's actually been tested...
>
>Help!
>
>Using PG:Pro ver 3, I've made a window with a check box, a static text
>field, and a pair of buttons. I'd like to change the state of the check
>box and the text in the static text field when the window gets built,
>making it appropriate to whatever the user is working on, not necessarily
>what it said during design time.
>
>Using FB2, I drew a user object in PG:Pro as the last object on the
>window (in front). Then in PG's event loop under "_otheruserinit", I put
>in code to set the text in the text field and to set the button status. I
>got this method from many examples I've seen posted over the years, and
>it works very nicely.
>
>However, this method doesn't work in FB3, as the user object isn't
>necessarily built or drawn last and in any case the order isn't
>predictable from one window to the next.
>
>Anyone have any suggestions how I can set the initial state of text
>fields and other controls in a PG window at run time (using PG3 and FB3)?
>Is there some new PG3 event I'm not aware of? Or should I just change the
>text and controls on the line following my PgBuild(_myWindow) statements
>and just cope with the window update events that they will generate?
>
>Thanks!
>

There is another way - just chnage the flags in the resource file used to build your items just before building the window (or even when the conditions necessitating the changes occur). You can look at the SAVE.FLTR (I think thats right) to see how it is done, or if these help:

'~'
'GetCheckbtn
'this function returns the state of a check
'button saved in a pg3w resource
'usefull when you need to read option settings

LOCAL FN GetBtn(theWnd,thebtn)
dim objElem, state

objElem = FN pGgetRef(theWnd,thebtn)

LONG IF objElem
state = gObjCtrlVal
END IF
END FN = state
'~'

'~'
'putCheckbtn
'this function changes the state of a check
'button saved in a pg3w resource
'usefull when you need to change option settings

LOCAL FN putBtn (theWnd,thebtn,theState)
dim objElem
objElem = FN pGgetRef(theWnd,thebtn)
LONG IF objElem
gObjCtrlVal = theState
FN pGputObj(theWnd,objElem)
END IF
END FN
'~'

'~'
'GetPG3String$
'this function returns the first 255 characters
'of text from a pG3t resource.
'usefull when you need to read option settings

LOCAL FN GetPG3String$(theWnd,theField)
DIM theStr$,elem
dim rHndl as handle
dim size

FN pGgetRef(theWnd,theField)
rHndl = FN GETRESOURCE(_"pG3t",gObjResID)
LONG IF rHndl
size = rHndl..nil%
IF size > 255 THEN size = 255
BLOCKMOVE [rHndl]+ 2,@theStr$ + 1,size
POKE @theStr$,size
XELSE
POKE @theStr$,0
END IF
CALL RELEASERESOURCE (rHndl)
END FN = theStr$
'~'

'~'
'PutPG3String
'this function changes the text in a
'pG3t resource (255 character limit).
'usefull when you need TO reset option settings

LOCAL FN PutPG3String (theWnd,theField,theText$)
dim strLen&
dim textHndl as handle
dim osErr

strLen&       = LEN(theText$)'length of string
textHndl     = FN NEWHANDLE _clear(strLen& + 2)'make new handle length of string + 2 for length in string info

LONG IF textHndl'handle made ok
FN HLOCK (textHndl)
OSerr = FN MEMERROR
LONG IF osErr = _noErr
POKE WORD [textHndl],strLen&'poke the length of the string into the handle
BLOCKMOVE @theText$+1,[textHndl]+2,strLen&'move the stuff into the handle'not @theString$

FN pGgetRef(theWnd,theField)'fill the global object record
FN pGreplaceRes (textHndl,_"pG3t",gObjResID,"")'replace the appropriate resource
FN HUNLOCK (textHndl)'unlock handle
FN DISPOSHANDLE (textHndl)'kill the handle
END IF
END IF

END FN = osErr'returns an error if problem
'~'