FileLoad Example for C++ 5.0 and later

// Add the following varables as Class members.
ILEADRasterDlgFile * m_pRasterFileDlg;
ILEADRasterDlgKrn * m_pRasterKrnDlg;
CRasterFileDlg * m_pRasterFileDlgsink;
unsigned long m_dwCookie;

BOOL CAllowMulDlg::OnInitDialog()
{
   .
   .
   .

   // TODO: Add extra initialization here

   m_pRasterKrnDlg = NULL;
   CoCreateInstance(CLSID_LEADRasterDlgKrn, NULL, CLSCTX_ALL, IID_ILEADRasterDlgKrn, (void**)&m_pRasterKrnDlg);

   m_pRasterKrnDlg->InitDlg(INIT_WITHOUT_COLOR);

   m_pRasterFileDlg=NULL;
   CoCreateInstance(CLSID_LEADRasterDlgFile, NULL, CLSCTX_ALL, IID_ILEADRasterDlgFile, (void**)&m_pRasterFileDlg);

   m_pRasterFileDlgsink= new CRasterFileDlg;
   LPUNKNOWN pUnkSink = m_pRasterFileDlgsink->GetIDispatch(FALSE);
   AfxConnectionAdvise(m_pRasterFileDlg, DIID__ILEADRasterDlgFileEvents, pUnkSink, FALSE, &m_dwCookie);

   return TRUE; // return TRUE unless you set the focus to a control
}

void CDialogs::ShowOpenDlg()
{
   m_pRasterFileDlg->DialogTitle= "LEADTOOLS Open dialog box";
   m_pRasterFileDlg->InitialDir= "c:\\images";
   m_pRasterFileDlg->FileDlgFlags= OPEN_ALLOWMULTI;

   m_pRasterFileDlg->UIFlags= OPEN_LOADBITMAP |
         OPEN_SHOW_PROGRESSIVE |
         OPEN_SHOW_MULTIPAGE |
         OPEN_SHOW_LOADROTATED |
         OPEN_SHOW_LOADCOMPRESSED |
         OPEN_SHOW_FILEINFO |
         OPEN_SHOW_PREVIEW |
         OPEN_SHOW_DELPAGE |
         OPEN_VIEWTOTALPAGES |
         OPEN_LOADBITMAP |
         OPEN_GENERATETHUMBNAIL;

   m_pRasterFileDlg->ShowOpenDlg((long)this->m_hWnd);
}

void CRasterFileDlg::OnFileLoad(int iTotalPercent,int iPercent)
{
   CDialogs * pDialog = (CAllowMulDlg*)AfxGetApp()->GetMainWnd();
   if (iPercent == 100)
   {
      long Bitmap = pDialog->m_pRasterFileDlg->GetBitmap();
      pDialog->m_RasterView.GetRaster().SetBitmap(Bitmap);
      MessageBox(0,pDialog->m_pRasterFileDlg->GetFileName(),0,0);
   }
}