Ok this is what I do in my WinMain ():
ZeroMemory(&OfnSts, sizeof(OPENFILENAME));
OfnSts.lStructSize = sizeof(OPENFILENAME);
OfnSts.lpstrFile = (char *)malloc(MAX_FILENAME_LEN);
OfnSts.nMaxFile = MAX_FILENAME_LEN;
OfnSts.Flags = OFN_FILEMUSTEXIST |
OFN_PATHMUSTEXIST | OFN_LONGNAMES | OFN_EXPLORER /*| OFN_EXPLORER */ ;
OfnSts.hInstance = hMainInstance;
OfnSts.lpfnHook = NULL;
OfnSts.hwndOwner = GetActiveWindow();
OfnSts.lpTemplateName = NULL;
OfnSts.lpstrFilter = filter;
OfnSts.lpstrInitialDir = NULL;
OfnSts.lpstrCustomFilter= NULL;
OfnSts.nFilterIndex = 1;
OfnSts.lpstrFileTitle = NULL;
OfnSts.lpstrDefExt = NULL;
The structure OfnSts is declared as a global OPENFILENAME .
In a subsequent call to a DialogBox , I just call
the GetOpenFileName (&ofnSts) .
This call always fails with a CDERR_INITIALIZATION error, no matter
what parameters I set in OfnSts.
Any idea ?
thanx
--- In [email protected], Thomas Hruska <[EMAIL PROTECTED]> wrote:
>
> spudgun0 wrote:
> > hi everybody,
> >
> > I'm making a small program which requires the user to specify the
name
> > and path of a file . I want to use a simple dialog which allow
the user
> > to browse through the file system and find the right file .
> > I've read on MSDN that a simple way for doing this is using the
> > GetOpenFileName (&ofn), after filling the OPENFILENAME ofn
structure.
> > Well, I've tried very possible combination of the parameters I
set in
> > the ofn structure , but there' s no way to make this dialog
appear .
> > What can be wrong?
>
> Show us what you've done. GetOpenFileName() works.
>
> --
> Thomas Hruska
> CubicleSoft President
> Ph: 517-803-4197
>
> *NEW* VerifyMyPC 2.4
> Change tracking and management tool.
> Reduce tech. support times from 2 hours to 5 minutes.
>
> http://www.CubicleSoft.com/VerifyMyPC/
>