Share via


CColorDialog::GetSavedCustomColors

CColorDialog objects permit the user, in addition to choosing colors, to define up to 16 custom colors.

static COLORREF * PASCAL GetSavedCustomColors( );

Return Value

A pointer to an array of 16 RGB color values that stores custom colors created by the user.

Remarks

The GetSavedCustomColors member function provides access to these colors. These colors can be retrieved after DoModal returns IDOK.

Each of the 16 RGB values in the returned array is initialized to RGB(255,255,255) (white). The custom colors chosen by the user are saved only between dialog box invocations within the application. If you wish to save these colors between invocations of the application, you must save them in some other manner, such as in an initialization (.INI) file.

Example

// Get a pointer to an array of 16 RGB color values that stores  
// custom colors created by the user from CColorDialog.
CColorDialog dlg;
if (dlg.DoModal() == IDOK)
{
   COLORREF* ccolor = dlg.GetSavedCustomColors();
   for (int i=0; i < 16; i++)
   {
      TRACE(_T("RGB value of the selected color - red = %u, ")
         _T("green = %u, blue = %u\n"),
         GetRValue(ccolor[i]), 
         GetGValue(ccolor[i]), 
         GetBValue(ccolor[i]));
   }
}

Requirements

Header: afxdlgs.h

See Also

Reference

CColorDialog Class

Hierarchy Chart

CColorDialog::GetColor