This small PB/DLL program demonstrates the use of the ChooseColor common dialog. If you change the two MSGBOX lines to PRINT and add a WAITKEY$ at the end, the program can also be compiled with PB/CC.
-------------
Perfect Sync: Perfect Sync Development Tools
Email: mailto:[email protected][email protected]</A>
[This message has been edited by Eric Pearson (edited March 01, 2000).]
Code:
$DIM ALL $REGISTER NONE $COMPILE EXE $INCLUDE "WIN32API.INC" $INCLUDE "COMDLG32.INC" FUNCTION PBMain AS LONG DIM ColorSpec AS LOCAL CHOOSECOLORAPI DIM lResult AS LOCAL LONG DIM lCounter AS LOCAL LONG DIM lCustomColor(15) AS LOCAL LONG 'array ColorSpec.lStructSize = LEN(ColorSpec) ColorSpec.hwndOwner = 0 'Handle of owner window. If 0, dialog appears at top/left. ColorSpec.lpCustColors = VARPTR(lCustomColor(0)) ColorSpec.rgbResult = 255 'set the default color to Red (255,0,0)... 'try these options one by one, for different effects... 'ColorSpec.Flags = ColorSpec.Flags OR %CC_RGBINIT 'tells control to start at default color 'ColorSpec.Flags = ColorSpec.Flags OR %CC_FULLOPEN 'ColorSpec.Flags = ColorSpec.Flags OR %CC_PREVENTFULLOPEN 'create a nice selection of colors for the custom colors (OPTIONAL)... RANDOMIZE TIMER FOR lCounter = 0 TO 15 lCustomColor(lCounter) = RND(0,16777215) 'or RGB(lCounter*16,0,(15-lCounter)*16) NEXT '(You could also load custom colors from a file, or hard-code them.) lResult = ChooseColor(ColorSpec) IF lResult = 0 THEN MSGBOX "You chose the Cancel button.",,"Color Selection Demo" ELSE MSGBOX "You chose color value &h"+HEX$(ColorSpec.rgbResult,6),,"Color Selection Demo" END IF 'You can also check then values in the lCustomColor() array to see if they've been changed. FUNCTION = 1 END FUNCTION
Perfect Sync: Perfect Sync Development Tools
Email: mailto:[email protected][email protected]</A>
[This message has been edited by Eric Pearson (edited March 01, 2000).]
Comment