1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
   | void CEFSViewerVCView::OnDraw(CDC* pDC)
{
   CEFSViewerVCDoc* pDoc = GetDocument();
   ASSERT_VALID(pDoc);
   // TODO: add draw code for native data here
   if (pDoc->m_OuvrirImage)
   {
      BITMAP bm;
      pDoc->m_bmpBitmap.GetBitmap(&bm);
 
      CDC dcMem;
 
      dcMem.CreateCompatibleDC(pDC);
      CBitmap * pOldBitmap=(CBitmap*)dcMem.SelectObject(pDoc->m_bmpBitmap);
      CRect lRect;
      GetClientRect(lRect);
      lRect.NormalizeRect();
      pDC->SetStretchBltMode(HALFTONE);  
      pDC->StretchBlt(0,0,bm.bmWidth,bm.bmHeight,&dcMem,0,0,bm.bmWidth,bm.bmHeight,SRCCOPY);
 
      this->Invalidate(false);
   }
}
 
void CEFSViewerVCDoc::OnFileOpen() 
{
   // TODO: Add your command handler code here
 
   // Crée un filtre pour la boite de dialogue Ouverture 
   static char BASED_CODE szFilter[]="Fichiers Bitmap (*.bmp)|*.bmp||";
 
   //Cree la boite de dialogue Ouverture
   CFileDialog m_ldFile(TRUE, ".bmp", m_sBitmap, OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT, szFilter);
 
   // Affiche la boite de dialogue Ouverture et capture le résultat
 
   if(m_ldFile.DoModal()==IDOK)
   {
      // Recupère le nom de fichier sélectionner
      m_sBitmap=m_ldFile.GetPathName();
      //Charge le fichier Bitmap
      HBITMAP hBitmap=(HBITMAP)::LoadImage(AfxGetInstanceHandle(), m_sBitmap, IMAGE_BITMAP, 0,0, LR_LOADFROMFILE|LR_CREATEDIBSECTION);
 
      //AVons nous un handle valide pour l'image chargé
      if(hBitmap)
      {
         //Supprime le bitmap courant
         if(m_bmpBitmap.DeleteObject())
         {
            m_bmpBitmap.Detach();
         }
         m_bmpBitmap.Attach(hBitmap);
         m_OuvrirImage=true;
      }
   }
} | 
Partager