ShowCustomizePaletteDlg Example for C++ 5.0 and later

void CDialog::OnShowCustomizePalletteDlg() 
{
   int nRet;
   m_pRasterColorDlg->UserPaletteCount = 256;
   for (int i= 0; i < 256; i ++ )
   {
      m_pRasterColorDlg->PutUserPalette(i,RGB(i,0,0));
   }

   m_pRasterColorDlg->UIFlags =  CUSTOMIZEPALETTE_SHOW_SORT                |
                                 CUSTOMIZEPALETTE_SHOW_FINDCLOSEST         |
                                 CUSTOMIZEPALETTE_SHOW_ADDOPTION           |
                                 CUSTOMIZEPALETTE_SHOW_REMOVEOPTION        |
                                 CUSTOMIZEPALETTE_SHOW_COLORMODEL          |
                                 CUSTOMIZEPALETTE_SHOW_RGBLEFTPAN          |
                                 CUSTOMIZEPALETTE_SHOW_HTMLLEFTPAN         |
                                 CUSTOMIZEPALETTE_SHOW_INDEXLEFTPAN        |
                                 CUSTOMIZEPALETTE_SHOW_RGBRIGHTPAN         |
                                 CUSTOMIZEPALETTE_SHOW_HTMLRIGHTPAN        |
                                 CUSTOMIZEPALETTE_SHOW_INDEXRIGHTPAN       |
                                 CUSTOMIZEPALETTE_SHOW_NEW                 |
                                 CUSTOMIZEPALETTE_SHOW_OPEN                |
                                 CUSTOMIZEPALETTE_SHOW_SAVE                |
                                 CUSTOMIZEPALETTE_SHOW_SAVEAS              |
                                 CUSTOMIZEPALETTE_GENERATE_PALETTE;

   m_pRasterColorDlg->Bitmap =  m_LeadRasterView.GetRaster ().GetBitmap();
   nRet= m_pRasterColorDlg->ShowCustomizePaletteDlg((long) this->m_hWnd);
   if ( nRet == 0 && m_pRasterColorDlg->DialogStatus == DLG_OK )
   {
      if ( m_pRasterColorDlg->ApplyPaletteWhenExit )
         MessageBox(TEXT("True"));
      else
         MessageBox(TEXT("False"));

      for (int i= 0; i < 256; i ++ )
      {
         m_pRasterProc->PutUserPalette(i, m_pRasterColorDlg->GetGeneratedPalette(i));
      }
   }
}