salut,
sur une source (http://www.cppfrance.com/code.aspx?ID=28478)
j'ai extrait une fonction de la librairy créé et ais essayé de la faire fonctioner, mais cela ne marche pas.
voyez vous une fautes ( dans mes variables parceque je ne sais pas tro quoi déclarer...) :
#include "file.h"
// mes initialisations de variables
char *extension [500];
char * descriptiontype [500];
HWND windowhandle;
bool VIEWERROR=0;
// la fonction :
int FILEOpenStandardDialogBoxOpenFile(char *extension, char* descriptiontype, HWND windowhandle, BOOL VIEWERROR)
{
char *fichierouvrir, *buffer;
int handle, i;
OPENFILENAME ofn; //Structure pour ouvrir la boite de dialogue "Ouvrir un fichier..."
fichierouvrir = (char*) calloc(FILESIZEBUFFER, sizeof(char));
buffer = (char*) calloc(FILESIZEBUFFER, sizeof(char));
// Initialisation de la structure OPENFILENAME
ZeroMemory(&ofn, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = windowhandle;
ofn.lpstrFile = fichierouvrir;
ofn.nMaxFile = FILESIZEBUFFER;
//on doit creer une chaine du type: "descriptiontype\0extension"
buffer = strcat(buffer, descriptiontype);
handle = strlen(buffer) + 1;
for (i = 0; i < 5 && *(extension + i) != '\0'; i++)
buffer[handle + i] = *(extension + i);
ofn.lpstrFilter = buffer;
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.lpstrTitle = strcat(FILETITREOPEN, extension);
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = _getcwd(NULL, FILESIZEBUFFER);
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
//Création de la fenètre d'ouverture d'un fichier
if (GetOpenFileName(&ofn) == TRUE)
{
if (handle = FILEOpen(fichierouvrir, VIEWERROR) != -1)
{
LocalFree(fichierouvrir);
return handle;
}
}
LocalFree(fichierouvrir);
return -1;
}