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
| void CChildView::OnFileOpen()
{
// Contexte de périphérique
CPaintDC dc(this);
CClientDC dcd(this);
// Pointeur sur la fenêtre principale
CMainFrame * pMainframe = (CMainFrame *) AfxGetApp()
->m_pMainWnd;
OPENFILENAME ofn;
CFile image;
int Taille;
TCHAR szFile[MAX_PATH] = TEXT("\0");
memset( &(ofn), 0, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.lpstrFile = szFile;
ofn.nMaxFile = MAX_PATH;
ofn.lpstrFilter = TEXT("All (*.*)\0*.*\0");
ofn.lpstrTitle = TEXT("Open File");
ofn.Flags = OFN_EXPLORER;
if (GetOpenFileName(&ofn))
{
MessageBox(ofn.lpstrFile, TEXT("Info"), MB_OK);
image.Open(ofn.lpstrFile, CFile::modeRead);
Taille = image.Read(buf3, 500);
image.Close();
// Création d'un bitmap avec le buffer
hbm = CreateBitmap(120,120,1,24,buf3);
hdcTemp.CreateCompatibleDC(&dcd);
hdcTemp.SelectObject(hbm);
GetObject(hbm, sizeof(BITMAP), &bm);
dcd.BitBlt(0, 0, 50, 50, &hdcTemp, 0, 0, SRCCOPY);
}
//Supprime le contexte mémoire
hdcTemp.DeleteDC();
//Supprime l'objet créé
DeleteObject(hbm);
} |
Partager