ChooseColor

  BOOL ChooseColor(lpcc)    
  LPCHOOSECOLOR lpcc; /* address of structure with initialization data */

The ChooseColor function creates a system-defined dialog box from which the user can select a color.

Parameters

lpcc

Points to a CHOOSECOLOR structure that initially contains information necessary to initialize the dialog box. When the ChooseColor function returns, this structure contains information about the user's color selection. The CHOOSECOLOR structure has the following form:

typedef struct { /* cc */

DWORD lStructSize;

HWND hwndOwner;

HWND hInstance;

DWORD rgbResult;

LPDWORD lpCustColors;

DWORD Flags;

DWORD lCustData;

LPCCHOOKPROC lpfnHook;

LPSTR lpTemplateName;

} CHOOSECOLOR;

Return Value

The return value is TRUE if the user chooses a color. It is FALSE if an error occurs, if the user chooses the Cancel button, or if the user chooses the Close command on the System menu (often called the Control menu) to close the dialog box.

Errors

Use the CommDlgExtendedError function to retrieve the error value, which may be one of the following:

CDERR_FINDRESFAILURE
CDERR_INITIALIZATION
CDERR_LOCKRESFAILURE
CDERR_LOADRESFAILURE
CDERR_LOADSTRFAILURE
CDERR_MEMALLOCFAILURE
CDERR_MEMLOCKFAILURE
CDERR_NOHINSTANCE
CDERR_NOHOOK
CDERR_NOTEMPLATE
CDERR_STRUCTSIZE

Comments

The dialog box does not support color palettes. The color choices offered by the dialog box are limited to the system colors and dithered versions of those colors.

If the hook function (to which the lpfnHook member of the CHOOSECOLOR structure points) processes the WM_CTLCOLOR message, this function must return a handle for the brush that should be used to paint the control background.