Example program - Choosing colors with Windows common dialog
This example uses $DECLARE to invoke a standard Windows component on the client which can pick a color interactively and return the RGB color value. For more on the Windows Common Dialogs see the MSDN site.
REM Using the Windows common dialog color chooser $DECLARE 'ChooseColor((INT(),INT(),INT(),INT(),TO RETURN DIM(),INT(),INT(),INT(),INT()))="comdlg32.ChooseColor" $DECLARE 'CommDlgExtendedError()="comdlg32.CommDlgExtendedError" $DECLARE 'GetActiveWindow() DIM nStructSize=9 * 4, hWndOwner, rgbColor=0, rgbDefColors$(16)4, hInstance=0 DIM c$(3)1, i, rc REM RGB components of the triple DIM _BLUE=1 DIM _GREEN=2 DIM _RED=3 REM available flags DIM _CC_RGBINIT=0x0001, _CC_FULLOPEN=0x0002, _CC_PREVENTFULLOPEN=0x0004, _CC_SHOWHELP=0x0008 DIM _CC_ENABLEHOOK=0x0010, _CC_SOLIDCOLOR=0x0080, _CC_ANYCOLOR=0x0100 REM set custom colors to white, preserve the values returned here for any subsequent call FOR i = 1 TO 16 rgbDefColors$(i) = HEX(00FF FFFF) NEXT i REM default is red say c$(_BLUE) = HEX(00) c$(_RED) = HEX(FF) c$(_GREEN) = HEX(00) rgbColor = VAL(c$(), 3) REM ensure dialog is owned by current window hWndOwner = 'GetActiveWindow() REM invoke the dialog IF ('ChooseColor(nStructSize, hWndOwner, hInstance, BYREF rgbColor, rgbDefColors$(), _CC_RGBINIT + _CC_SOLIDCOLOR + _CC_FULLOPEN, 0, 0, 0)) REM non-zero result means OK c$() = BIN(rgbColor, 3) rc = 0 ELSE REM zero result above means ESC or error, get reason rc==0 means ESC, +ve is an error rc = 'CommDlgExtendedError() END IF