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
|
void CEssaiView::OnNouvelleimageOpen()
{
// 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);
//ou CStatic * hWndViewer = (CStatic*) GetDlgItem(IDC_VIEWER);
// Load the bitmap
HBITMAP hBitmap = (HBITMAP) LoadImage( 0,
pathName,
IMAGE_BITMAP,
0,0,
LR_LOADFROMFILE |
LR_LOADMAP3DCOLORS |
LR_SHARED );
//hWndViewer->SetBitmap(hBitmap);
// 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;
} |
Partager