FileFormatsCount Example for C++ 5.0 and later

void CDialogs::OnFileSave()
{
	HRESULT hr;
	int nRet;

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

	ILEADRasterDlgFile_U *m_pRasterDlgFile = NULL;
	hr = CoCreateInstance(CLSID_LEADRasterDlgFile_U,
		NULL,
		CLSCTX_ALL,
		IID_ILEADRasterDlgFile_U,
		(LPVOID*)&m_pRasterDlgFile);

	nRet = m_pRasterDlgKrn->InitDlg(INIT_WITH_COLOR);

	m_pRasterDlgFile->DialogTitle = "Save a File";

	m_pRasterDlgFile->InitialDir = "C:\\"; 
	m_pRasterDlgFile->FileFormatsCount = 2; 

	m_pRasterDlgFile->GetFileFormats(0)->PutFormat(FF_SAVE_LEAD); 
	m_pRasterDlgFile->GetFileFormats(0)->PutBitsPerPixelCount(1); 
	m_pRasterDlgFile->GetFileFormats(0)->PutBitsPerPixelFormat(0, 24); 
	m_pRasterDlgFile->GetFileFormats(0)->PutSubFormat(0, FF_SAVE_SUB_CMP_NONPROGRESSIVE | FF_SAVE_SUB_CMP_PROGRESSIVE); 

	m_pRasterDlgFile->GetFileFormats(1)->PutFormat(FF_SAVE_TIFF); 
	m_pRasterDlgFile->GetFileFormats(1)->PutBitsPerPixelCount(1); 
	m_pRasterDlgFile->GetFileFormats(1)->PutBitsPerPixelFormat(0,24); 
	m_pRasterDlgFile->GetFileFormats(1)->PutSubFormat(0,
		FF_SAVE_SUB_TIFF1_CCITT | 
		FF_SAVE_SUB_TIFF1_CCITT_G3_1D | 
		FF_SAVE_SUB_TIFF1_CCITT_G3_2D | 
		FF_SAVE_SUB_TIFF1_CCITT_G4 |
		FF_SAVE_SUB_TIFF1_UNCOMPRESSEDRGB |
		FF_SAVE_SUB_TIFF1_RLERGB |
		FF_SAVE_SUB_TIFF1_LZWRGB |
		FF_SAVE_SUB_TIFF1_JBIG); 

	m_pRasterDlgFile->UIFlags = SAVE_AUTOPROCESS |
		SAVE_SHOW_FILEOPTIONS_PROGRESSIVE |
		SAVE_SHOW_FILEOPTIONS_MULTIPAGE |
		SAVE_SHOW_FILEOPTIONS_STAMP |
		SAVE_SHOW_FILEOPTIONS_QFACTOR |
		SAVE_SHOW_FILEOPTIONS_J2KOPTIONS |
		SAVE_SHOW_FILEOPTIONS_BASICJ2KOPTIONS; 

	m_pRasterDlgFile->Bitmap = m_pLead1.GetBitmap();
	m_pRasterDlgFile->ShowSaveDlg((long)this->m_hWnd);
}