Panel użytkownika
Nazwa użytkownika:
Hasło:
Nie masz jeszcze konta?

Problem z GetSaveFileName() i wskaźnikami

Ostatnio zmodyfikowano 2011-08-18 12:42
Autor Wiadomość
DejaVu
» 2011-08-18 11:07:20
Czytałeś MSDN'a? Nie. Pisałem Ci już to. Wszystko palcem trzeba pokazać?
http://msdn.microsoft.com/en-us/library/ms646839(v=vs.85).aspx

lpstrFile


The file name 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, file name, 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 file names of the selected files. For Explorer-style dialog boxes, the directory and file name strings are NULL separated, with an extra NULL character after the last file name. For old-style dialog boxes, the strings are space separated and the function uses short file names for file names with spaces. You can use the FindFirstFile function to convert between long and short file names. If the user selects only one file, the lpstrFile string does not have a separator between the path and file name.

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

The size, in characters, of the buffer pointed to by lpstrFile. The buffer must be large enough to store the path and file name string or strings, including the terminating NULL character. 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.
P-39406
xevuel
Temat założony przez niniejszego użytkownika
» 2011-08-18 11:33:47

Czytałeś MSDN'a? Nie.
Zawsze czytam MSDN-a jeszcze przed zadaniem pytania.


The size, in characters, of the buffer pointed to by...
Czyli sugerujesz, że błąd jest w lini
ofn.nMaxFile = 4096;
? Powinienem to zastąpić
ofn.nMaxFile = filename.size();
, tak?
P-39407
DejaVu
» 2011-08-18 11:42:27
Sugeruję przeczytać co to pole znaczy i się to tego zastosować. Ja nie używam ani tej struktury ani tej funkcji, więc nie mam potrzeby doczytywania się jak to dokładnie działa. Taki to marny los programisty, że część swego życia spędza na czytaniu dokumentacji :)
P-39408
xevuel
Temat założony przez niniejszego użytkownika
» 2011-08-18 11:45:52

Ja nie używam ani tej struktury ani tej funkcji, więc nie mam potrzeby doczytywania się jak to dokładnie działa.
o_O to ja po miesiącu nauki C++ i WinAPI odczułem potrzebę skorzystania z tej struktury, a ty po kilku latach nie? :P

Stosuję się do zaleceń i kosztuje mnie to nerwy stracone na doszukiwaniu się nie wiadomo jakich błędów przy wskaźnikach...
P-39409
DejaVu
» 2011-08-18 12:42:42
Bo doszukujesz się błędów zamiast doczytać dokumentację ;p

/edit:
http://msdn.microsoft.com/en-us/library/ms646928(v=vs.85).aspx

If the user specifies a file name and clicks the OK button and the function is successful, the return value is nonzero. The buffer pointed to by the lpstrFile member of the OPENFILENAME structure contains the full path and file name specified by the user.
Wniosek: bufor musi mieć możliwość zapisu, czyli:
C/C++
TCHAR bufor[ 123 ];
struktura.lpstrFile = bufor;
struktura.nMaxFile = 123;
Ot cała filozofia.
P-39414
1 2 « 3 »
Poprzednia strona Strona 3 z 3