Pb avec nMaxFile dans CFileDialog vc++

cs_pichu Messages postés 28 Date d'inscription dimanche 9 mars 2003 Statut Membre Dernière intervention 8 juin 2005 - 16 avril 2003 à 17:38
ManTico Messages postés 11 Date d'inscription mercredi 20 août 2003 Statut Membre Dernière intervention 21 juillet 2005 - 24 mars 2006 à 15:16
Dans une CFileDialog on est limité dans le nombre de selection si on en selectionne plusieurs
le pb est que je veux etre illimite dans le nombre
Comment je peux faire car la doc dit "The buffer should be at least 256 characters long". Auriez vous une astuce svp??
merci

4 réponses

BruNews Messages postés 21040 Date d'inscription jeudi 23 janvier 2003 Statut Modérateur Dernière intervention 21 août 2019
16 avril 2003 à 19:37
Quel rapport avec "at least 256 characters long" ?
Tu mets 50000 si tu veux, du moment que c'est AU MOINS 256.
BruNews, ciao...
0
cs_pichu Messages postés 28 Date d'inscription dimanche 9 mars 2003 Statut Membre Dernière intervention 8 juin 2005
17 avril 2003 à 08:49
je me suis tronpé de phrase (j'ai pris un trop court extrait qui n'avais rien a voir dsl)
c'était :
"
lpstrFile
Pointer to a buffer that contains a filename used to initialize the File Name edit control. The first character of this buffer must be NULL if initialization is not necessary. When the GetOpenFileName or GetSaveFileName function returns successfully, this buffer contains the drive designator, path, filename, and extension of the selected file.
If the OFN_ALLOWMULTISELECT flag is set and the user selects multiple files, the buffer contains the current directory followed by the filenames of the selected files. For Explorer-style dialog boxes, the directory and filename strings are NULL separated, with an extra NULL character after the last filename. For old-style dialog boxes, the strings are space separated and the function uses short filenames for filenames with spaces. You can use theFindFirstFile function to convert between long and short filenames.

If the buffer is too small, the function returns FALSE and the CommDlgExtendedError function returns FNERR_BUFFERTOOSMALL. In this case, the first two bytes of the lpstrFile buffer contain the required size, in bytes or characters.

nMaxFile
Specifies the size, in bytes (ANSI version) or 16-bit characters (Unicode version), of the buffer pointed to by lpstrFile. The GetOpenFileName and GetSaveFileName functions return FALSE if the buffer is too small to contain the file information. The buffer should be at least 256 characters long. "

mais ils ne disent pas comment allouer un buffer plus grand
j'ai essaye de comprnedre ca :

"To allow the user to select multiple files, set the OFN_ALLOWMULTISELECT flag before calling DoModal. You need to supply your own filename buffer to accommodate the returned list of multiple filenames. Do this by replacing m_ofn.lpstrFile with a pointer to a buffer you have allocated, after constructing the CFileDialog, but before calling DoModal. Additionally, you must set m_ofn.nMaxFile with the number of characters in the buffer pointed to by m_ofn.lpstrFile."

mais j'arrive pas en faisant
LPTSTR buf;
CFileDialog fd(....)
fd.m_ofn.lpstrFile= buf;
fd.m_ofn..nMaxFile =1000;

ca plante...
la je pense avoir tout dit sur mon pb...
merci
0
cs_pichu Messages postés 28 Date d'inscription dimanche 9 mars 2003 Statut Membre Dernière intervention 8 juin 2005
17 avril 2003 à 09:58
c'est bon j'ai trouvé
il fallait
faire :
char C[1000];
fd.m_ofn.lpstrFile=C;
fd.m_ofn.nMaxFile=sizeof(C)+10;

si on met pas au moins +8, ca marche pas..
0
ManTico Messages postés 11 Date d'inscription mercredi 20 août 2003 Statut Membre Dernière intervention 21 juillet 2005 1
24 mars 2006 à 15:16
Je sais que cette discussion date de longtemps, mais ayant eu le problème aujourd'hui, j'ai une remarque à faire.

Il n'est pas nécessaire d'ajouter 10 ou 8 pour fd.m_ofn.nMaxFile, mais il faut mettre le premier char à NULL :

C[0] = NULL;



Et là celà fonctionne sans autre.
0
Rejoignez-nous