ShowCustomizePaletteDlg Example for C++ 5.0 and later

void CDialog::OnShowCustomizePalletteDlg()
{
	HRESULT hr;
	int nRet;

	ILEADRasterDlgKrn_U *m_pRasterDlgKrn = NULL;
	hr = CoCreateInstance(CLSID_LEADRasterDlgKrn_U,
		NULL,
		CLSCTX_ALL,
		IID_ILEADRasterDlgKrn_U,
		(LPVOID*)&m_pRasterDlgKrn);

	ILEADRasterDlgClr_U *m_pRasterDlgClr = NULL;
	hr = CoCreateInstance(CLSID_LEADRasterDlgClr_U,
		NULL,
		CLSCTX_ALL,
		IID_ILEADRasterDlgClr_U,
		(LPVOID*)&m_pRasterDlgClr);

	nRet = m_pRasterDlgKrn->InitDlg(INIT_WITH_COLOR);

	m_pRasterDlgClr->UserPaletteCount = 256;

	for (int i = 0; i < 256; i++)
	{
		m_pRasterDlgClr->PutUserPalette(i, RGB(i,0,0));
	}

	m_pRasterDlgClr->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_pRasterDlgClr->Bitmap = m_pLead1.GetBitmap();
	nRet = m_pRasterDlgClr->ShowCustomizePaletteDlg((long)m_hWnd);

	if (nRet == 0 && m_pRasterDlgClr->DialogStatus == DLG_OK)
	{
		if (m_pRasterDlgClr->ApplyPaletteWhenExit)
			MessageBox(TEXT("True"));
		else
			MessageBox(TEXT("False"));

		for (int i = 0; i < 256; i++)
		{
			m_pLead1.put_UserPalette(i, m_pRasterDlgClr->GetUserPalette(i));
		}
	}
}