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

OpenFileDialog HookProc and a question

31 views
Skip to first unread message

Michael Covington

unread,
Jul 13, 2009, 10:40:30 AM7/13/09
to
I've just been looking at OpenFileDialog's HookProc...

Does this enable a way of letting people choose folders rather than
files? I'd like something that works just like an OpenFileDialog but
allows choosing a folder as an alternative to choosing a file.
(FolderBrowserDialog is rather clunky by comparison.)

In either WPF or WinForms.

Thanks to anyone with useful thoughts to contribute.

Jeff Johnson

unread,
Jul 13, 2009, 11:17:36 AM7/13/09
to
"Michael Covington" <for.addr...@www.ai.uga.edu.slash.mc> wrote in
message news:OppNaf8A...@TK2MSFTNGP04.phx.gbl...

> (FolderBrowserDialog is rather clunky by comparison.)

Really? I've always thought that the folder browser was much more elegant
than the Open dialog for picking a folder. Using the latter always felt like
a kludge to me. Oh well, to each his own.


Peter Duniho

unread,
Jul 13, 2009, 1:33:47 PM7/13/09
to
On Mon, 13 Jul 2009 07:40:30 -0700, Michael Covington
<for.addr...@www.ai.uga.edu.slash.mc> wrote:

> I've just been looking at OpenFileDialog's HookProc...
>
> Does this enable a way of letting people choose folders rather than
> files?

No. I admit, I'm not even sure why they bothered to document it.
OpenFileDialog is sealed and HookProc is protected. There's no way to
call it from client code, never mind override it.

If you want to be able to select folders from the OpenFileDialog, I think
your best bet is to just use the native common dialogs directly, either
via p/invoke or with your own managed C++ wrapper. I'm sure there's a way
to hack the OpenFileDialog class itself, but I can't imagine that would be
less work and/or more reliable than just going to the native API directly.

Pete

Michael Covington

unread,
Jul 13, 2009, 8:13:05 PM7/13/09
to

My recollection is that FolderBrowserDialog doesn't see or follow links.
Is that right?

TechSupport

unread,
Jul 14, 2009, 7:51:45 AM7/14/09
to
Michael, you can use common dialog components from Dialog
Workshop.NET
(see www.componentage.com for details).

There us a sample which shows how to use CaOpenFileDialog component
for folder selection.

Hope this helps.

Alex

0 new messages