Dialog box error - check code [modified]
-
I have class derived from CFileDialog that keeps failing when I select to many files (4-5 works fine). My problem is that I want to find out why it is failing, but the only way I can find to do this is by using CommDlgExtendedError(). However, I cannot check the return code against the values as stated in MSDN because they don't actually seem to be defined anywhere(including Commdlg.h). I don't know if this is a VS2005 issue or not. The code being returned is 12291. Any suggestions? Dustin -- modified at 17:29 Tuesday 24th April, 2007
-
I have class derived from CFileDialog that keeps failing when I select to many files (4-5 works fine). My problem is that I want to find out why it is failing, but the only way I can find to do this is by using CommDlgExtendedError(). However, I cannot check the return code against the values as stated in MSDN because they don't actually seem to be defined anywhere(including Commdlg.h). I don't know if this is a VS2005 issue or not. The code being returned is 12291. Any suggestions? Dustin -- modified at 17:29 Tuesday 24th April, 2007
12291 == 0x3003 == FNERR_BUFFERTOOSMALL Clearly documented in the SDK under CommDlgExtendedError()... "The CommDlgExtendedError function returns a common dialog box error code. This code indicates the most recent error to occur during the execution of one of the common dialog box functions. These error codes are defined in Cderr.h." ;P
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
-
12291 == 0x3003 == FNERR_BUFFERTOOSMALL Clearly documented in the SDK under CommDlgExtendedError()... "The CommDlgExtendedError function returns a common dialog box error code. This code indicates the most recent error to occur during the execution of one of the common dialog box functions. These error codes are defined in Cderr.h." ;P
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
Now what are the odds that the answer would be in the first line of the help file.:) I did actually find that a few minutes ago and have been trying to increase my buffer size by changing the OPENFILENAME.nMaxFile, but this is appearantly causing memory to be over written and failing on initialization of the dialog. I'm getting an access violation error and the call stack shows only assembly. Any idea how to correctly increase the buffer size? Dustin
-
Now what are the odds that the answer would be in the first line of the help file.:) I did actually find that a few minutes ago and have been trying to increase my buffer size by changing the OPENFILENAME.nMaxFile, but this is appearantly causing memory to be over written and failing on initialization of the dialog. I'm getting an access violation error and the call stack shows only assembly. Any idea how to correctly increase the buffer size? Dustin
Dustin Henry wrote:
Now what are the odds that the answer would be in the first line of the help file.
:laugh: that's the reason for my smart-alec reply :) Increasing OPENFILENAME.nMaxFile isn't the only thing you need to do. You also need to increase the size of the buffer pointed to by OPENFILENAME.lpstrFile. //example DWORD dwMaxFileLength = MAX_PATH * 10; MyOFN.lpstrFile = new TCHAR[dwMaxFileLength]; MyOFN.nMaxFile = dwMaxFileLength; ... delete[] MyOFN.lpstrFile;
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
-
Dustin Henry wrote:
Now what are the odds that the answer would be in the first line of the help file.
:laugh: that's the reason for my smart-alec reply :) Increasing OPENFILENAME.nMaxFile isn't the only thing you need to do. You also need to increase the size of the buffer pointed to by OPENFILENAME.lpstrFile. //example DWORD dwMaxFileLength = MAX_PATH * 10; MyOFN.lpstrFile = new TCHAR[dwMaxFileLength]; MyOFN.nMaxFile = dwMaxFileLength; ... delete[] MyOFN.lpstrFile;
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
That fixed it. Thanks for the help Mark.:)
-
That fixed it. Thanks for the help Mark.:)
No problem! I thought I'd mention that "MAX_PATH * 10" was arbitrary. It may be a good idea to consider how many files a typical user will select normally and adjust the size accordingly. You'll have one path and how ever many filenames. I have no personal set formula. I chose MAX_PATH * 32 in my apps for multiple-select file dialogs for no reason other than that's the first thing that came to mind and roughly 8K (16K for Unicode) bytes of temporary memory is cheap :) I bet 1/10th of that has never been exceeded :laugh:. Have fun! Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
-
I have class derived from CFileDialog that keeps failing when I select to many files (4-5 works fine). My problem is that I want to find out why it is failing, but the only way I can find to do this is by using CommDlgExtendedError(). However, I cannot check the return code against the values as stated in MSDN because they don't actually seem to be defined anywhere(including Commdlg.h). I don't know if this is a VS2005 issue or not. The code being returned is 12291. Any suggestions? Dustin -- modified at 17:29 Tuesday 24th April, 2007
Can't you use the Error Lookup (errlook.exe) tool that ships with VS?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
Can't you use the Error Lookup (errlook.exe) tool that ships with VS?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
Probably he got the error code ERR_ASK_AT_CP