CHOOSECOLOR

typedef struct { /* cc */

DWORD lStructSize;

HWND hwndOwner;

HWND hInstance;

DWORD rgbResult;

LPDWORD lpCustColors;

DWORD Flags;

DWORD lCustData;

LPCCHOOKPROC lpfnHook;

LPSTR lpTemplateName;

} CHOOSECOLOR;

The CHOOSECOLOR structure contains information that the system uses to initialize the system-defined color selection dialog box. After the user dismisses the dialog box, the system returns information about the user's selection in this structure.

Members

lStructSize

Specifies the length of the structure (in bytes).

hwndOwner

Identifies the window that owns the dialog box. This member can be any valid window handle, or NULL if the dialog box has no owner.

hInstance

Identifies a data block that contains dialog template specified by the lpTemplateName member. This member is only used if the Flags member specifies the CC_ENABLETEMPLATE flag; otherwise, this member is ignored.

rgbResult

Specifies the color that is initially selected when the dialog box is created, and contains the user's color selection when the dialog box is dismissed. On creation, if the CC_RGBINIT flag is set in the Flags member and the value of this member is not among the colors available, the system will select the nearest solid color available. If this member is NULL, the initially-selected color is black.

lpCustColors

Points to an array of 16 DWORDs that contain 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. An application should save these values for future calls to the ChooseColor function.

Flags

Specifies the dialog-box initialization flags. This member may be a combination of the following values:

Value Meaning

CC_ENABLEHOOK Enables the hook function specified in the lpfnHook member.
CC_ENABLETEMPLATE Causes the system to create the dialog box using the dialog template identified by the hInstance and lpTemplateName members.
CC_ENABLETEMPLATEHANDLE Indicates that the hInstance member identifies a data block that contains a pre-loaded dialog template. The system ignores the lpTemplateName member if this flag is specified.
CC_FULLOPEN Causes the entire dialog box to appear when the dialog box is created, including the portion that allows the user to create custom colors. Without this flag, the user must select the “Define Custom Color . . . ” push button to see this portion of the dialog box.
CC_PREVENTFULLOPEN Disables the “Define Custom Colors . . . ” push button, preventing the user from creating custom colors.
CC_RGBINIT Causes the dialog box to use the color specified in the rgbResult member as the initial color selection.
CC_SHOWHELP Causes the dialog box to show the Help push button. The hwndOwner member must not be NULL if this option is specified.

lCustData

Specifies application-defined data that the system passes to the hook function identified by the lpfnHook member. The system passes the data in the lParam field of the WM_INITDIALOG message.

lpfnHook

Points to a hook function that processes messages intended for the dialog box. An application must specify the CC_ENABLEHOOK function in the Flags member to enable the function; otherwise, the system ignores this structure member. The hook function must return FALSE to pass a message on to the standard color dialog procedure, or TRUE to discard the message.

lpstrTemplateName

Points to a null-terminated string that names the dialog box template resource to be substituted for the standard dialog template. An application can use the MAKEINTRESOURCE macro for numbered dialog resources. This member is only used if the Flags member specifies the CC_ENABLETEMPLATE flag; otherwise, this member is ignored.

See Also

ChooseColor