ChooseColor Function

Comdlg32.h | Comdlg32.lib

ChooseColor Function

Displays a system-color-common dialog box that allows the user to select a color.

BOOL ChooseColor(
    LPSHORTCUTMENU lpChooseColor
);

Parameters

Parameter Description
lpChooseColor A pointer to a CHOOSECOLOR structure that contains the attributes of the color-common dialog box. The CHOOSECOLOR structure can be initialized by default or with any desired values before calling this function.

Return Value

If the user clicks the OK button, the return value is nonzero. This is the only way the dialog box can be dismissed successfully.

If the user clicks the Cancel button, cancels the dialog box, or an error occurs, the return value is zero. To get extended error information, call GetLastError.

Remarks

The ChooseColor function creates a modal color-common dialog box.

To initialize the dialog box, the CHOOSECOLOR structure pointed to by lpChooseColor must be filled with appropriate values. The lpTemplateName member must be NULL, and the hInstance member must be NULL.

If the CC_RGBINIT flag is set in the Flags member of the CHOOSECOLOR structure, the rgbResult member must be initialized to the desired initial color. Otherwise, the dialog box displays the default system color.

If the CC_FULLOPEN flag is set, the dialog box will be displayed with theexpanded color settings already visible.

If the CC_ENABLEHOOK flag is set, the lpfnHook member of the CHOOSECOLOR structure must point to a hook procedure that processes messages intended for the dialog box. The hook procedure must have the same signature as a window procedure. For more information, see Hooks.

If the CC_ENABLETEMPLATE flag is set, the lpTemplateName member must point to a null-terminated string that specifies the resource name of the dialog box template. The hInstance member must identify the module that contains the template.

Example

For a sample application that uses this function, see Color Picker Sample.

Requirements

| |
Minimum supported client Windows 2000 Professional
Minimum supported server Windows 2000 Server
Header Comdlg32.h (include Windows.h)
Library Comdlg32.lib
DLL Comdlg32.dll