ShowWindowLevelDlg Example for C++ 5.0 and later

void CDialogs::OnShowWindowLevelDlg()
{
	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->WindowLevelLow = m_pLead1.GetMinVal();
	m_pRasterDlgClr->WindowLevelHigh = m_pLead1.GetMaxVal();
	m_pRasterDlgClr->WindowLevelFactor = 0;

	switch (m_pLead1.GetIsGrayscale())
	{
	case GRAY_ORDEREDNORMAL:
		m_pRasterDlgClr->StartColor = RGB(0, 0, 0);
		m_pRasterDlgClr->EndColor = RGB(255, 255, 255);
		break;
	case GRAY_ORDEREDREVERSE:
		m_pRasterDlgClr->StartColor = RGB(255, 255, 255);
		m_pRasterDlgClr->EndColor = RGB(0, 0, 0);
		break;
	case GRAY_NOTORDERED:
		m_pRasterDlgClr->StartColor = RGB(0, 0, 0);
		m_pRasterDlgClr->EndColor = RGB(255, 255, 255);
		break;
	default: AfxMessageBox(TEXT("Not Supported")); exit(0);
	}

	m_pRasterDlgClr->WindowLevelFlags = FILL_LUT_OUTSIDE | FILL_LUT_LINEAR;
	m_pRasterDlgClr->UIFlags = WINDOWLEVEL_SHOW_PREVIEW |
		WINDOWLEVEL_SHOW_TOOL_ZOOMLEVEL |
		WINDOWLEVEL_SHOW_RANGE |
		WINDOWLEVEL_AUTOPROCESS;

	m_pRasterDlgClr->Bitmap = m_pLead1.GetBitmap();

	nRet = m_pRasterDlgClr->ShowWindowLevelDlg((long)m_hWnd);

	if (nRet == 0 && m_pRasterDlgClr->DialogStatus == DLG_OK) 
	{
		m_pLead1.WindowLevelFillLUT(m_pRasterDlgClr->StartColor,
			m_pRasterDlgClr->EndColor,
			m_pRasterDlgClr->Low,
			m_pRasterDlgClr->High,
			m_pRasterDlgClr->LowBit,
			m_pRasterDlgClr->HighBit,
			m_pRasterDlgClr->WindowLevelLow,
			m_pRasterDlgClr->WindowLevelHigh,
			m_pRasterDlgClr->WindowLevelFactor,
			m_pRasterDlgClr->WindowLevelFlags);
	}
}