可以使用CColorDialog打开选择如下颜色对话框
其构造函数如下:
CColorDialog(
COLORREF clrInit = 0, //默认颜色,为空则为RGB(0,0,0)(黑色)
DWORD dwFlags = 0, //介绍如下
CWnd* pParentWnd = NULL //父窗口
);
);
-
Flags:
-
CC_ANYCOLOR
- Causes the dialog box to display all available colors in the set of basic colors. CC_ENABLEHOOK
-
Enables the hook procedure specified in the
lpfnHook member of this structure. This flag is used only to initialize the dialog box.
CC_ENABLETEMPLATE
-
Indicates that the
hInstance and lpTemplateName members specify a dialog box template to use in place of the default template. This flag is used only to initialize the dialog box.
CC_ENABLETEMPLATEHANDLE
-
Indicates that the
hInstance member identifies a data block that contains a preloaded dialog box template. The system ignores the lpTemplateName member if this flag is specified. This flag is used only to initialize the dialog box.
CC_FULLOPEN
- Causes the dialog box to display the additional controls that allow the user to create custom colors. If this flag is not set, the user must click the Define Custom Color button to display the custom color controls. 全部展开颜色对话框,从而可以自己指定颜色 CC_PREVENTFULLOPEN
- Disables the Define Custom Color button. CC_RGBINIT
-
Causes the dialog box to use the color specified in the
rgbResult member as the initial color selection. - 使用指定的颜色作为对话框打开时的初始颜色(可以在构造函数指定初始颜色或使用会话框的m_cc.rgbResult 来指定) CC_SHOWHELP
-
Causes the dialog box to display the Help button. The
hwndOwner member must specify the window to receive the HELPMSGSTRING registered messages that the dialog box sends when the user clicks the Help button.
CC_SOLIDCOLOR
- Causes the dialog box to display only solid colors in the set of basic colors.
最后可以通过GetColor()函数得到COLORREF类型的颜色,再用GetXValue得到具体的颜色值。
如使用如下
void CEnvParaTab::OnBnClickedButtonClearco
{
}