Share via


ChooseColor

This function creates a Color common dialog box that enables the user to select a color.

BOOL ChooseColor(
LPCHOOSECOLOR lpcc);

Parameters

  • lpcc
    Long pointer to a CHOOSECOLOR structure that contains information used to initialize the dialog box. When ChooseColor returns, this structure contains information about the users color selection.

Return Values

If the user clicks the OK button of the dialog box, the return value is nonzero. The rgbResult member of the CHOOSECOLOR structure contains the RGB color value of the color selected by the user.

If the user cancels or closes the Color dialog box or an error occurs, the return value is zero. To get extended error information, call the CommDlgExtendedError function, which can return one of the following values:

CDERR_FINDRESFAILURE CDERR_MEMALLOCFAILURE
CDERR_INITIALIZATION CDERR_NOHINSTANCE
CDERR_LOCKRESFAILURE CDERR_NOHOOK
CDERR_LOADRESFAILURE CDERR_NOTEMPLATE
CDERR_LOADSTRFAILURE CDERR_STRUCTSIZE

Remarks

The Color common dialog does not support user-defined colors if the target device screen is less than 480 pixels in width. In this case, the CC_FULLOPEN and CC_PREVENTFULLOPEN flags are ignored.

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

You can provide a CCHookProc hook procedure for a Color dialog box. The hook procedure can process messages sent to the dialog box. To enable a hook procedure, set the CC_ENABLEHOOK flag in the Flags member of the CHOOSECOLOR structure and specify the address of the hook procedure in the lpfnHook member.

Requirements

Runs On Versions Defined in Include Link to
Windows CE OS 2.0 and later Commdlg.h   Commdlg.lib

Note   This API is part of the complete Windows CE OS package as provided by Microsoft. The functionality of a particular platform is determined by the original equipment manufacturer (OEM) and some devices may not support this API.

See Also

CCHookProc, CHOOSECOLOR, CommDlgExtendedError

 Last updated on Tuesday, July 13, 2004

© 1992-2000 Microsoft Corporation. All rights reserved.