FB II Compiler

PG PRO

Debugging

Memory

System

Mathematics

Resources

Disk I/O

Windows

Controls

Menus

Mouse

Keyboard

Text

Fonts

Drawing

Sound

Clipboard

Printing

Communication

ASM

Made with FB

DRAWING

Make a picture of an Edit Field


LOCAL FN editField(resHndl&,@rectPtr&)

  DIM t,l,b,r

  LONG IF resHndl&
    hState = FN HGETSTATE(resHndl&)
    OSErr = FN HLOCK(resHndl&)
    t;8 = rectPtr&
    TEHndl& = FN TESTYLNEW(t,t)
    FN pGTEHooks(TEHndl&) ' <- Only if you are using PG

    % [TEHndl&] + _temode, _srcor

    LONG IF TEHndl&
      resSz& = FN GETHANDLESIZE(resHndl&)
      txtSz = {[resHndl&]}
      stylSz = resSz& - (txtSz + 2 )
      styl& = FN NEWHANDLE(stylSz)
      LONG IF styl&
        BLOCKMOVE [resHndl&] + txtSz + 2,[styl&],stylSz
        LONG IF stylSz > 2
          CALL TESTYLINSERT([resHndl&]+2,txtSz,styl&,TEHndl&)
        XELSE
          CALL TEINSERT([resHndl&]+2,txtSz,TEHndl&)
        END IF

        DEF DISPOSEH(styl&)
      END IF '[blk2&]
      CALL TEDISPOSE(TEHndl&)
    END IF '[TEHndl&]
    OSErr = FN HSETSTATE(resHndl&,hState)
  END IF '[resHndl&]
END FN

DIM rect.8
CALL SETRECT(rect, x1, y1, x2, y2)
PICTURE ON (x1, y1)-(x2, y2)
FN editField(resHndl&, rect)
PICTURE OFF, pictHndl&

(This assumes that you have already loaded ZTXT data into to the block referenced by resHndl&.)

SG et Rick