CFileDialog Initial Dir
Hi, I want to open an open file dialog, I can manage it fine, the thing I am having the problem with is telling it a different default directory.
I have created a structure of OPENFILENAME and am setting the lpstrInitialDir to the path I want to start at, but when I pass it to the CFileDialog constructor it errors saying:
cannot convert parameter 4 from 'struct tagOFNA' to 'unsigned long.
I have read and re-read and I don;t know what to do, this is all before DoModal() is called.
Post the call to CFileDialog constructor. One possible solution is pointer. Pass in the address of the structure.
Hi Kuphryn, thanks.
I tried passing the addrtess but it has teh same error.
Here is my call:
defdir.lpstrInitialDir = m_jobdir;
CFileDialog findcpr(true, ".cpr", NULL, defdir, "cpr files (*.cpr)||All Files (*.*)||");
I have just had another look and it may be the fact I am asking it to equal a CString, rather than a pointer to a character array.
I just tried passing it a pointer to a char array and it has the same error when using the constructor.
Can anyone see what I am doing wrong?
I had just been reading the documentation wrong.
I was trying to pass it an OPENFILENAME structure in the place it wanted a DWORD to modify the look of the dialog box.
Instead I needed to edit the m_ofn structure that is a member of the CFileDialog class, like this.
and there you have it the initial directory is what I want it to be.
CFileDialog findcpr(true, ".cpr", NULL, NULL, "cpr files (*.cpr)||All Files (*.*)||");
findcpr.m_ofn.lpstrInitialDir = m_jobdir;