virtual BOOL OnColorOK( );
Return Value
Nonzero if the dialog box should not be dismissed; otherwise 0 to accept the color that was entered.
Remarks
Override this function only if you want to provide custom validation of the color entered into the dialog box. This function allows you to reject a color entered by a user into a common color dialog box for any application-specific reason. Normally, you do not need to use this function because the framework provides default validation of colors and displays a message box if an invalid color is entered.
Use the GetColor member function to get the RGB value of the color.
If 0 is returned, the dialog box will remain displayed in order for the user to enter another filename.
Example
// Override OnColorOK to validate the color entered to the
// Red, Green, and Blue edit controls. If the color
// is BLACK (i.e. RGB(0, 0,0)), then force the current color
// selection to be the color initially selected when the
// dialog box is created. The color dialog won't close so
// user can enter a new color.
BOOL CMyColorDialog::OnColorOK( )
{
// Value in Red edit control.
if (GetDlgItemInt(COLOR_RED) == 0 &&
// Value in Green edit control.
GetDlgItemInt(COLOR_GREEN) == 0 &&
// Value in Blue edit control.
GetDlgItemInt(COLOR_BLUE) == 0)
{
AfxMessageBox("BLACK is not an acceptable color.
Please enter a color again");
// GetColor() returns initially selected color.
SetCurrentColor(GetColor());
// Won't dismiss color dialog.
return TRUE;
}
// OK to dismiss color dialog.
return FALSE;
}