ShowUnderlayDlg Example for C++ 5.0 and later

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

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

	ILEADRasterDlgImgEfx_U *m_pRasterDlgImgEfx = NULL;
	hr = CoCreateInstance(CLSID_LEADRasterDlgImgEfx_U, 
		NULL,
		CLSCTX_ALL,
		IID_ILEADRasterDlgImgEfx_U,
		(LPVOID*)&m_pRasterDlgImgEfx);

		nRet = m_pRasterDlgKrn->InitDlg(INIT_WITH_COLOR);

	m_pRasterDlgImgEfx->ItemsCount = 3; 
	m_pRasterDlgImgEfx->PutItemFileName(0, "D:\\Images\\Vista\\Dock.jpg");
	m_pRasterDlgImgEfx->PutItemFileName(1, "D:\\Images\\Vista\\Creek.jpg");
	m_pRasterDlgImgEfx->PutItemFileName(2, "D:\\Images\\Vista\\Forest.jpg");

	for (int i = 0; i < m_pRasterDlgImgEfx->ItemsCount; i++)
	{
		m_pLead1.Load(m_pRasterDlgImgEfx->GetItemFileName(i), 0, 0, 1); 
		m_pRasterDlgImgEfx->PutItemDescription(i, m_pRasterDlgImgEfx->GetItemFileName(i)); 
		m_pRasterDlgImgEfx->PutItemBitmap(i, m_pLead1.GetBitmap());
	}

	m_pRasterDlgImgEfx->ImageEffectFlags = UNDERLAY_TILE; 
	m_pRasterDlgImgEfx->UIFlags = UNDERLAY_SHOW_PREVIEW |
		UNDERLAY_SHOW_TOOL_ZOOMLEVEL;

	m_pRasterDlgImgEfx->Bitmap = m_pLead1.GetBitmap();
	nRet = m_pRasterDlgImgEfx->ShowUnderlayDlg((long)m_hWnd);

	if (nRet == 0 && m_pRasterDlgImgEfx->DialogStatus == DLG_OK)
	{
		m_pLead1.Underlay(m_pRasterDlgImgEfx->SelectedBitmap, m_pRasterDlgImgEfx->ImageEffectFlags); 
	}
}