Hi Jose, the AfxChooseColorDialog code found in AfxWin.inc may need a little tweak. I am using the function to allow WinFBE users to select a custom color. Works perfectly but if the dialog is cancelled it returns a value of 0 which is of course a valid color (black).
So, maybe instead of having the function return a COLORREF, probably change that to a LONG (unsigned valued) so we can return a value of -1 to indicate that the dialog was closed.
' ========================================================================================
' Displays the choose color dialog.
' - hParent = Handle to the parent window or null.
' - rgbDefaultColor = Optional. Initial default color.
' - lpCustColors = Optional. A pointer to an array of 16 values that contain red, green,
' blue (RGB) values for the custom color boxes in the dialog box. If the user modifies
' these colors, the system updates the array with the new RGB values.
' Return value: The selected color.
' ========================================================================================
PRIVATE FUNCTION AfxChooseColorDialog (BYVAL hParent AS HWND, BYVAL rgbDefaultColor AS COLORREF = 0, BYVAL lpCustColors AS COLORREF PTR = NULL) AS LONG
DIM ColorSpec AS CHOOSECOLORW, lCustomColor(15) AS LONG
ColorSpec.lStructSize = SIZEOF(ColorSpec)
ColorSpec.hwndOwner = hParent ' // Handle of owner window. If 0, dialog appears at top/left.
IF lpCustColors = NULL THEN
FOR lCounter AS LONG = 0 TO 15
lCustomColor(lCounter) = BGR(0, lCounter * 16, (15 - lCounter) * 16)
NEXT
ColorSpec.lpCustColors = VARPTR(lCustomColor(0))
ELSE
ColorSpec.lpCustColors = lpCustColors
END IF
ColorSpec.rgbResult = rgbDefaultColor
ColorSpec.Flags = ColorSpec.Flags OR CC_RGBINIT OR CC_FULLOPEN
Function = Iif( ChooseColorW(@ColorSpec), Colorspec.rgbResult, -1)
End Function
' ========================================================================================
I have implemented this change with my set of includes and it works perfectly.