Salut Virginie,
Pour te montrer le comment, voici un extrait de code basé sur la technique que je t'ai donné. Dans ce cas, cette méthode ouvre une fenêtre standard d'ouverture de fichier et affiche le bitmap demandé dans le cadre défini par mon control picture. Si tu as besoin j'ai un exemple complet qui fonctionne que je peux te fournir.
void CMyMFCBmpViewerDlg::OnFileBitmapOpen()
{
// szFilters is a text string that includes two file name filters:
// "*.bmp" for "Bitmap Files" and "*.*' for "All Files."
char szFilters[]=
"MyType Files (*.bmp)|*.bmp|All Files (*.*)|*.*||";
// Create an Open dialog;
// the default file name extension is ".bmp".
CFileDialog fileDlg (TRUE, "", "*.bmp",
OFN_FILEMUSTEXIST| OFN_HIDEREADONLY, szFilters, this);
// Display the file dialog. When user clicks OK,
// Display the bitmap in picture control of my dialog box
if( fileDlg.DoModal ()==IDOK )
{
CString pathName = fileDlg.GetPathName();
// Implement opening and reading file in here.
// Get handle on picture control window
CWnd * hWndViewer = this->GetDlgItem(IDC_VIEWER);
// Load the bitmap
HBITMAP hBitmap = (HBITMAP) LoadImage( 0,
pathName.GetString(),
IMAGE_BITMAP,
0,0,
LR_LOADFROMFILE |
LR_LOADMAP3DCOLORS |
LR_SHARED );
// Associate picture to the control
hWndViewer->SendMessage( STM_SETIMAGE,
(WPARAM) IMAGE_BITMAP,
(LPARAM) hBitmap );
//Change the window's title to the opened file's title.
CString fileName = fileDlg.GetFileTitle ();
SetWindowText(fileName);
}
return;
}
@+ Lord Woden ;o)