[futurebasic] Re: [FB] Static edit field problem

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : May 2002 : Group Archive : Group : All Groups

From: Alain Pastor <pixmix@...>
Date: Thu, 23 May 2002 14:58:28 +0200
Douglas Stemen wrote:
> 
> The following example code demonstrates the bug with static edit fields that
> I am experiencing in my accounting program.
> 
> In this example, a regular edit field can be made static and then return to
> non-static.
> 
> A static edit field cannot be made non-static.
> 
<snip>
I'm not sure it is doable under the Appearance Runtime. Edit Fields
are controls with the Appearance and I don't think you can change the
type of a control on the fly.
I would suggest to create two different fields and swap them on screen
as needed or perhaps something like this.

'~'A
'                       Runtime : Rntm Appearance.Incl
'~'B

_editableEF = 1
_staticEF   = 2

LOCAL FN BuildWindow
  DIM r AS RECT

  WINDOW -1
  
  SetRect( r, 10, 10, 450, 60 )
  EDIT FIELD _editableEF, "", @r,_framedNoCR_usePlainFrame_noDrawFocus,_rightJust

  OffsetRect( r, WINDOW(_width), 0 )
  EDIT FIELD _staticEF,"",@r,_statFramed,_rightJust

  SetRect( r, 100, 100 ,200, 12 5)
  APPEARANCE BUTTON 1, _activeBtn,,,, "Click me", @r, _kControlPushButtonProc

  EDIT FIELD _editableEF

  WINDOW 1

END FN


LOCAL FN ChangeFieldType
  DIM AS RECT r1,r2
  DIM teH AS ..TERec

  teH = TEHANDLE( _editableEF )
  LONG IF teH
    r1  = teH..viewRect
    teH = TEHANDLE( _staticEF )
    LONG IF teH
      r2 = teH..viewRect
      SWAP r1,r2
      EDIT$( _staticEF ) = EDIT$( _editableEF )
      EDIT FIELD _editableEF,,@r1
      EDIT FIELD _staticEF  ,,@r2
    END IF
  END IF

END FN


LOCAL FN doDialog
  DIM AS LONG act, ref

  act = DIALOG( 0 )
  ref = DIALOG( act )

  IF act = _btnClick AND ref = 1 THEN FN ChangeFieldType

END FN


FN BuildWindow

ON DIALOG FN doDialog
DO
  HANDLEEVENTS
UNTIL _nil
-- 
Cheers,

Alain

-- 
Cheers,

Alain