Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to change folder in an Openfiledialog using a hook...

237 views
Skip to first unread message

Zeroeffect

unread,
Feb 18, 2003, 3:00:21 PM2/18/03
to
I want to add 4 buttons to the right of the openfile dialog.
When the user clicks a button, I want the dialog to change to
a folder that I have "stored" in the button. For examples
c:\projects\2003\a\

I have made the template and the hook, and they work very well!
But I don't know how I should do to make the button change the folder.
There is a lot of messages to query the openfiledialog, but very few
where you could set a value.

One way, mayby not the most beautiful one, would be to set the text in
the editbox where the user should enter the name of the file he wants
to open, and then simulate a click on the Open button. That will make
the openfiledialog to change folder, but I don't manage to simulate a
mouseclick on the open button!

Any suggestions?

Im using Visual Studio 6, and Im writing in plain C for W2K / NT

Thanks
// Marcus

Damian Driscoll

unread,
Feb 18, 2003, 5:45:57 PM2/18/03
to

"Zeroeffect" <poub...@hotmail.com> wrote in message
news:93f8903.03021...@posting.google.com...

Here's a copy of an answer I posted nearly a year ago...

What I do is to read the contents of 'edt1' (the edit control containing the
default filename), replace it with the directory name which I want to be
displayed in the list box, simulate a click on the OK button, and then stick
the original text back in the 'edt1' control.

The code could look something like this:

void ChangeDir(HWND wOfn,TCHAR *NewDir)
{
TCHAR s[MAX_PATH];

/* backup contents of 'edt1' */
GetDlgItemText(wOfn,edt1,s,MAX_PATH);
/* replace with the directory name */
SendMessage(wOfn,CDM_SETCONTROLTEXT,edt1,(LPARAM)NewDir);
/* click on the OK button */
SendMessage(wOfn,WM_COMMAND,IDOK,0);
/* restore contents of 'edt1' */
SendMessage(wOfn,CDM_SETCONTROLTEXT,edt1,(LPARAM)s);
}

UINT CALLBACK OpenHookProc(HWND w,UINT msg,WPARAM wParam,LPARAM lParam)
{
int r=0;

switch(msg)
{
case WM_INITDIALOG:
/* call this from wherever is suitable, only here for an example */
ChangeDir(GetParent(w),TEXT("D:\\bbb"));
r=1;
break;
case CDN_INITDONE:
r=1;
break;
/* ... */
}

return r;
}

Damian

Zeroeffect

unread,
Feb 19, 2003, 2:31:18 AM2/19/03
to
Thanks alot!! Wonderful!

marilena...@gmail.com

unread,
Dec 12, 2013, 5:10:19 AM12/12/13
to
thanks!!
0 new messages