Our app allows multiple files to be selected in a file selection dialog which is shown via the GetOpenFileName function (this question also applies to folks using CFileDialog, etc…)
There appears to be a limit to the number of characters that can be typed into the filename field (259 seems to be the magic number – not sure why).
We have tried changing the following members of the OPENFILENAME structure:
lpstrFile – point to our own buffer, sized at 4K bytes nMaxFile – set to the size of lpstrFile (we are compiling ANSI, so this is effectively 4000
But these values appear to not increase the input width of the filename field in the dialog.
I am going to experiment with sending a EM_SETLIMITTEXT message to the control, but wanted to know if anyone else has a solution.
EDIT – solved this myself: solution I can’t accept out my own answer, but here it is for posterity. If anyone else has a better solution, please post it – or feel free to mod up my solution so future searchers will find it at the top.
Turns out that the edit control (At least in my development environment) is a combo box, so
EM_SETLIMITTEXTisn’t appropriate.Instead, I tracked down the combo box using
GetDlgCtrlon the parent of the file open dialog (I do this in theOnInitDialoghandler), cast it toCComboBox*, then callLimitText()to set the limit.This could also be done by sending a
CB_LIMITTEXTmessage to the control for those of you who are not working withCFileDialog. The appropriate value here is most likely theOPENFIILENAME.nMaxFilevalue that is passed in.