ShowSaveDlg 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->FileDlgFlags = 0; 
	m_pRasterDlgFile->InitialDir = "C:\\";         
	m_pRasterDlgFile->SaveMulti = MULTIPAGE_OVERWRITE; 
	m_pRasterDlgFile->UIFlags = 
		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();
	nRet = m_pRasterDlgFile->ShowSaveDlg((long)m_hWnd);

	if (nRet == 0 && m_pRasterDlgFile->DialogStatus == DLG_OK)
	{
		CString csOut; 
		CString csTemp; 
		csTemp.Format(TEXT("File: %s\n"), (LPCTSTR)m_pRasterDlgFile->GetFileName());
		csOut = csTemp;
		csTemp.Format(TEXT("BPP: %d\n"), m_pRasterDlgFile->SaveBitsPerPixel);
		csOut += csTemp;
		csTemp.Format(TEXT("Format: %d\n"), m_pRasterDlgFile->SaveFormat); 
		csOut += csTemp; 
		csTemp.Format(TEXT("QFactor: %d\n"), m_pRasterDlgFile->SaveQFactor); 
		csOut += csTemp; 
		csTemp.Format(TEXT("SaveMulti: %d : Page#: %d\n"),
			m_pRasterDlgFile->SaveMulti, m_pRasterDlgFile->PageNumber); 
		csOut += csTemp; 
		csTemp.Format(TEXT("SaveProgressive: %d\n"), m_pRasterDlgFile->SaveProgressive); 
		csOut += csTemp; 
		csTemp.Format(TEXT("SavePasses: %d\n"), m_pRasterDlgFile->SavePasses); 
		csOut += csTemp; 
		csTemp.Format(TEXT("SaveStamp: %d\n"), m_pRasterDlgFile->SaveWithStamp); 
		csOut += csTemp; 
		csTemp.Format(TEXT("StampBits: %d\n"), m_pRasterDlgFile->SaveStampBits); 
		csOut += csTemp; 
		csTemp.Format(TEXT("StampWidth: %d\n"), m_pRasterDlgFile->SaveStampWidth); 
		csOut += csTemp; 
		csTemp.Format(TEXT("StampHeight: %d\n"), m_pRasterDlgFile->SaveStampHeight); 
		csOut += csTemp; 
		csTemp.Format(TEXT("Interlaced: %d\n"), m_pRasterDlgFile->SaveInterlaced); 
		AfxMessageBox(csOut);
	}
}