void CMainFrame::OnPenColor() { // array of custom colors, initialized to white static COLORREF CustColors[16] = { RGB(255,255,255), RGB(255,255,255), RGB(255,255,255), RGB(255,255,255), RGB(255,255,255), RGB(255,255,255), RGB(255,255,255), RGB(255,255,255), RGB(255,255,255), RGB(255,255,255), RGB(255,255,255), RGB(255,255,255), RGB(255,255,255), RGB(255,255,255), RGB(255,255,255), RGB(255,255,255) }; CColorDialog ColorDlg; ColorDlg.SetCustomColors(CustColors); // Initialize the Choose Color dialog if (ColorDlg.DoModal(*this) == IDOK) { // Store the custom colors in the static array memcpy(CustColors, ColorDlg.GetCustomColors(), 16*sizeof(COLORREF)); // Retrieve the chosen color m_View.SetPenColor(ColorDlg.GetColor()); } }