#include <commdlg.h>
typedef struct tagCHOOSECOLOR { /* cc */
DWORD lStructSize;
HWND hwndOwner;
HWND hInstance;
COLORREF rgbResult;
COLORREF FAR* lpCustColors;
DWORD Flags;
LPARAM lCustData;
UINT (CALLBACK* lpfnHook)(HWND, UINT, WPARAM, LPARAM);
LPCSTR lpTemplateName;
} CHOOSECOLOR;
The CHOOSECOLOR structure contains information that the system uses to initialize the system-defined Color dialog box. After the user chooses the OK button to close the dialog box, the system returns information about the user's selection in this structure.
lStructSize
Specifies the length of the structure, in bytes. This member is filled on input.
hwndOwner
Identifies the window that owns the dialog box. This member can be any valid window handle, or it should be NULL if the dialog box is to have no owner.
If the CC_SHOWHELP flag is set, hwndOwner must identify the window that owns the dialog box. The window procedure for this owner window receives a notification message when the user chooses the Help button. (The identifier for the notification message is the value returned by the RegisterWindowMessage function when HELPMSGSTRING is passed as its argument.)
This member is filled on input.
hInstance
Identifies a data block that contains the dialog box template specified by the lpTemplateName member. This member is used only if the Flags member specifies the CC_ENABLETEMPLATE or CC_ENABLETEMPLATEHANDLE flag; otherwise, this member is ignored. This member is filled on input.
rgbResult
Specifies the color that is initially selected when the dialog box is displayed, and specifies the user's color selection after the user has chosen the OK button to close dialog box. If the CC_RGBINIT flag is set in the Flags member before the dialog box is displayed and the value of this member is not among the colors available, the system selects the nearest solid color available. If this member is NULL, the first selected color is black. This member is filled on input and output.
lpCustColors
Points to an array of 16 doubleword values, each of which specifies the intensities of the red, green, and blue (RGB) components of a custom color box in the dialog box. If the user modifies a color, the system updates the array with the new RGB values. This member is filled on input and output.
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 use the dialog box template identified by the hInstance member and pointed to by the lpTemplateName member. |
CC_ENABLETEMPLATEHANDLE | Indicates that the hInstance member identifies a data block that contains a pre-loaded dialog box template. If this flag is specified, the system ignores the lpTemplateName member. |
CC_FULLOPEN | Causes the entire dialog box to appear when the dialog box is displayed, including the portion that allows the user to create custom colors. Without this flag, the user must select the Define Custom Color button to see that portion of the dialog box. |
CC_PREVENTFULLOPEN | Disables the Define Custom Colors 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 button. If this flag is specified, the hwndOwner member must not be NULL. |
These flags are used when the structure is initialized.
lCustData
Specifies application-defined data that the system passes to the hook function pointed to by the lpfnHook member. The system passes a pointer to the CHOOSECOLOR structure in the lParam parameter of the WM_INITDIALOG message; this pointer can be used to retrieve the lCustData member.
lpfnHook
Points to a hook function that processes messages intended for the dialog box. To enable the hook function, an application must specify the CC_ENABLEHOOK value in the Flags member; otherwise, the system ignores this structure member. The hook function must return zero to pass a message that it didn't process back to the dialog box procedure in COMMDLG.DLL. The hook function must return a nonzero value to prevent the dialog box procedure in COMMDLG.DLL from processing a message it has already processed. This member is filled on input.
lpTemplateName
Points to a null-terminated string that specifies the name of the resource file for the dialog box template that is to be substituted for the dialog box template in COMMDLG.DLL. An application can use the MAKEINTRESOURCE macro for numbered dialog box resources. This member is used only if the Flags member specifies the CC_ENABLETEMPLATE flag; otherwise, this member is ignored. This member is filled on input.
Some members of this structure are filled only when the dialog box is created, and some have an initialization value that changes when the user closes the dialog box. Whenever a description in the Members section does not specify how the value of a member is assigned, the value is assigned only when the dialog box is created.