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

RESOURCES

Add a custom item in a dialog for color picking


' To run this demo you will have to build
' a resources file named here "DLOG.rsrc" with
' a DLOG resource (ID 128) and its associated DITL
' with item 1 : OK button, item 2 : cancel button
' item 3 : a static text, item 4 : a user item
RESOURCES "DLOG.rsrc"
GLOBALS
_OK = 1
_cancel = 2
_myUserItem = 4
_myDLOG = 128
DIM gtheColor.rgbColor
DIM gItemHit
END GLOBALS
'========
CLEAR LOCAL
DIM theItem,Itype,Ihandle&,Irect.8
LOCAL FN showColor(DLOGptr&)
  CALL GETDITEM(DLOGptr&,_myUserItem,Itype,Ihandle&,Irect)
  CALL RGBFORECOLOR(gtheColor)
  CALL PAINTRECT(Irect)
  COLOR _zblack
  CALL PENSIZE (2,2)
  CALL FRAMERECT(Irect)
END FN
'========
CLEAR LOCAL
DIM RGBin.rgbColor
DIM RGBout.rgbColor
DIM wherePt.4
DIM msg$
LOCAL FN choseColor(DLOGptr&)
  RGBin=gtheColor
  wherePt.h = 50 : wherePt.v = 50
  msg$ = "Pick a color (any color)!"
  picked = FN GETCOLOR(wherePt, msg$, RGBin, RGBout)
  IF picked THEN gtheColor=RGBout
END FN
'========
CLEAR LOCAL
DIM oldcolor.rgbcolor
LOCAL FN showDialog(whichDLOG)
  oldColor=gtheColor
  CALL GETPORT(oldWnd&)
  DLOGptr&=FN GETNEWDIALOG(whichDLOG,0,-1)
  LONG IF DLOGptr&
    CALL SETPORT(DLOGptr&)
    CALL DRAWDIALOG(DLOGptr&)
    FN showColor(DLOGptr&)
    DO
      CALL MODALDIALOG(0,gItemHit)
      LONG IF gItemHit = _myUserItem
        FN choseColor(DLOGptr&)
        FN showColor(DLOGptr&)
      END IF
    UNTIL gItemHit=_OK OR gItemHit=_cancel
    IF gItemHit=_cancel THEN gtheColor=oldcolor
    CALL SETPORT(oldWnd&)
    CALL DISPOSDIALOG(DLOGptr&)
  END IF
END FN
'========
FN showDialog(_myDLOG)

Alain