[futurebasic] Re: [FB] Embedding Edit Fields?

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : February 2003 : Group Archive : Group : All Groups

From: Ken Shmidheiser <kshmidheiser@...>
Date: Tue, 11 Feb 2003 05:31:48 -0500
>On Monday, February 10, 2003, at 07:47  pm, mckernon wrote:
>
>>  Once again, I venture into the unknown...
>>
>>  I would like to be able to use edit fields inside the area enclosed by
>>  a
>>  kControlGroupBoxSecondaryTextTitleProc control. However, the only way I
>>  can see to make edit fields (plain, unstyled is fine) is with EDIT
>>  FIELD..., and DEF EMBEDBUTTON evidently can't embed those kinds edit
>>  fields (I get a runtime error).
>>
>>  In any event, edit fields won't take mouse clicks, keypresses, or
>>  anything when they occupy space within the GroupBox's rectangle, so
>>  clearly they need to be embedded to work.
>>
>>  The ADC web site has precious little to say, although it does mention
>>  that text input fields are a kind of control. But there's nothing I can
>>  find about how to build an Appearance-compliant edit field.
>>
>>  Anybody else been through this?
>>
>>  If this isn't possible, I'll just redesign the window...:(
>>
>>  Thanks --
>>
>>  - John
>>
>>
>
>Hi John,
>
>Yes I have been through this, and RP was kind enough to supply the code
>below :
>
>local mode
>dim efPaneControlRef as handle
>dim err              as OSErr
>local fn EmbedEFinButton(  efNum as long, btnNum as long )
>efPaneControlRef = fn FBFindEF( efNum, _allEFSubClasses, 0 )
>err = fn EmbedControl( efPaneControlRef, button&( btnNum ) )
>if err then stop "EmbedEFinButton error " + str$( err )
>end fn
>
>Best Regards
>Ian


One little caveat R.P. mentioned concerning this technique:

Edit fields were not designed to be embedded in another control. 
Techniques such as fn EmbedEFinButton are useful but not fully 
planned. When the embedder is closed, the contained EFs are therefore 
not disposed properly.

This sets you up for trouble if you later re-create any embedded edit fields:

if button&(_parentEFDelete) then button close _parentEFDelete '   :-(


You should always close the embedded EFs before closing the embedder control:

long if button&( _parentEFDelete )
  edit field close _efDelete1 '     :-)
  edit field close _efDelete2 '     :-)
  button close _parentEFDelete
end if

This might help prevent trouble down the road.

Ken