Bonjour a toutes et a tous,
Ma question est peut etre bete, mais je cherche a ouvrir des images bmp dans un programme en C++.
Je choisis le fichier à ouvrir grace a la boite de Dialogue Commune: Ouvrir Fichier. ( J'ai donc des noms de fichiers et des Chemins Différents à chaque fois ou presque..)
J'ai essayé :
Mais ca j'ai comme message : Impossible d'ouvrir le Fichier: C:\Documents
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 #include <windows.h> #include <fstream> // Ein- u. Ausgabe von Dateien #include <conio.h> #include <stdio.h> using namespace std; #include "Open BMP File.h" void Open_fileBMP() { OPENFILENAME ofn; HWND hwnd = NULL; char szFile4[560]; char szCmd[300]; ZeroMemory(&ofn, sizeof(ofn)); #ifdef OPENFILENAME_SIZE_VERSION_400 ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; #else ofn.lStructSize = sizeof(ofn); #endif ofn.hwndOwner = hwnd; ofn.lpstrFile = szFile4; ofn.lpstrFile[0] = '\0'; ofn.nMaxFile = sizeof(szFile4); ofn.lpstrFilter = "Bmp\0*.BMP\0"; ofn.nFilterIndex = 1; ofn.lpstrFileTitle = NULL; ofn.nMaxFileTitle = 0; ofn.lpstrInitialDir = NULL; ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_EXPLORER | OFN_ALLOWMULTISELECT; if (GetOpenFileName(&ofn)) { char* szNameBMP = szFile4; strcpy(szCmd, "\"C:\\WINNT\\System32\\MSPAINT\" "); strcat(szCmd,szNameBMP); WinExec(szCmd, SW_SHOW); } }
Sans doute par ce que mon fichier se trouve dans Documents and Settings....
aie aie aie...
C'est sans doute pas difficile.. ou si vous avez une autre methode...
Merci d'avance...
Anna
Partager