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
| HBITMAP hBitmap;
CString nomImage;
CString cheminImage;
bool openfile;
void Ctest2Dlg::OnBnClickedButton8()
{
// TODO : ajoutez ici le code de votre gestionnaire de notification de contrôle
// Création de la boite de dialogue d'ouverture de fichiers
CString OpenFilter;
OpenFilter = "All Files (*.*)|*.*||";
CFileDialog dialogOuvrir(TRUE, NULL,NULL,OFN_FILEMUSTEXIST|OFN_HIDEREADONLY|OFN_PATHMUSTEXIST,OpenFilter,AfxGetMainWnd());
if( dialogOuvrir.DoModal ()==IDOK )
{
cheminImage = dialogOuvrir.GetPathName();
openfile = true ;
CWnd * hWndViewer = this->GetDlgItem(IDC_STATIC_PICTURE);
CDC * dcControlePicture = hWndViewer->GetDC ();
nomImage = dialogOuvrir.GetFileName();
MessageBox(nomImage,NULL);
// Chargement du bitmap
hBitmap = (HBITMAP)LoadImage( 0, dialogOuvrir.m_ofn.lpstrFileTitle, IMAGE_BITMAP, 0,0, LR_LOADFROMFILE| LR_CREATEDIBSECTION | LR_DEFAULTSIZE);
// Associer IMAGE au control PictureBox
hWndViewer->SendMessage( STM_SETIMAGE,
(WPARAM) IMAGE_BITMAP,
(LPARAM) hBitmap );
Invalidate();
UpdateData (FALSE);
}
return; |
Partager