Tech Support > Microsoft Windows > Development Resources > Re: Win2k API "open file" dialogue box help
Re: Win2k API "open file" dialogue box help
Posted by Alf P. Steinbach on October 14th, 2003


On Mon, 13 Oct 2003 22:56:25 GMT, dearmrf <dearmrf@yahoooooo.com> wrote:
The only way I can find is using some undocumented functionality
(which of course may change in the future...), see below.



I've crossposted this answer to [comp.os.ms-windows.programmer.win32].

However, it may be that in spite of posting to [comp.programming] you're
not asking a programming question but a Windows configuration question,
in which case both the answer and the new group is probably irrelevant...



================================================== ========================
#include <cstddef> // std::size_t

#define STRICT
#include <windows.h>

#define _WIN32_WINNT 0x501 // XP or better
#include <commctrl.h> // LVM_SETVIEW

UINT const wmSetViewMode = WM_APP + 1; // Arbitrary


template< typename T, std::size_t N >
std::size_t elemCount( T const (&)[N] ){ return N; }

static UINT_PTR CALLBACK ofnHookProc(
HWND hdlg,
UINT uiMsg,
WPARAM wParam,
LPARAM lParam
)
{
if( uiMsg == WM_NOTIFY && reinterpret_cast<LPNMHDR>(lParam)->code == CDN_INITDONE )
{
PostMessage( hdlg, wmSetViewMode, 0, 0 );
}
else if( uiMsg == wmSetViewMode )
{
HWND const dlg = GetParent( hdlg );
HWND const defView = GetDlgItem( dlg, lst2 );
SendMessage( defView, WM_COMMAND, 28716, 0 );
}
return 0;
} // ofnHookProc

int main()
{
char fileSpec[MAX_PATH] = ""; // Must be initialized.

OPENFILENAME dialogData =
{
sizeof( dialogData ),
0, // Owner window handle
0, // Instance handle for template
"All [*.*]\0*.*\0", // Filters
NULL, // Custom filter memory
0, // Size in tchars of custom filter memory
1, // Filter index, 1-based
fileSpec, // Buffer for user's choice
static_cast<DWORD>( elemCount( fileSpec ) ),
NULL, // Buffer for non-qualified filename
0, // Size in tchars of above buffer
"c:\\", // Initial directory
"A title",
0
//| OFN_DONTADDTORECENT
| OFN_ENABLESIZING
| OFN_EXPLORER
| OFN_PATHMUSTEXIST
| OFN_ENABLEHOOK,
0, // Output filename offset
0, // Output file extension offset
NULL, // Default filename extension
0, // Hook data
&ofnHookProc, // Hook
NULL // Template name
};

GetOpenFileName( &dialogData );
}


Posted by dearmrf on October 16th, 2003


On Tue, 14 Oct 2003 02:04:34 GMT, alfps@start.no (Alf P. Steinbach)
wrote:

( I already replied to this, but I'll try again, since it's not
showing up in either group??)

that's great, thx!!

problem is I'm not a programmer, so I don't know what to do with all
that?

I did copy it into notepad, but do I have to run it as a script or
something? how can I set it up so it runs when I trigger the "open
file" dialogue?

I'm not above figuring it out myself, if someone wants to just submit
a basic prohramming link?

thx


fwiw I'm pretty sure it's not a windows configuration issue, I've
looked all over the net and win2k for any reference to this. out of
sheer desperation I figured I'd post to a programming NG, figured
somebody out there would know somewthing about it?

thx again, much appreciated!!

Posted by Alf P. Steinbach on October 16th, 2003


On Thu, 16 Oct 2003 00:06:01 GMT, dearmrf <dearmrf@yahoooooo.com> wrote:

You don't, it's example code showing one way to force details view in the
common open file dialog when you make your own application.



There seems to be no way to configure Windows for a particular default view.

However, you can run some application that intercepts those dialog boxes and
switches them to details view, probably using some technique like the one
presented in the above code.

See "freeware" in
<url: http://www.laurenceholbrook.com/TechnicalInformation/Win2KProfessionalCommonDialogBox.html>

This was the first I found using Google for "windows open file dialog view".


Posted by dearmrf on October 16th, 2003


On Thu, 16 Oct 2003 00:29:45 GMT, alfps@start.no (Alf P. Steinbach)
wrote:


well, don't I feel like a Tit.....

of course, being the moron I am, I didn't know what terminology to
use in the search engines.


good news is, I just tried this freeware app out that I found thru
your link

http://www.netcult.ch/elmue/ElmueSoft-en.htm

and IT WORKS!!!!!!!

YEEEHAAAA!!!!!

thank you, thank you, thank you!!!!

you have no idea how friggin' annoying this stupid issue has been for
me. you made my friggin' week.....!!

hahaha oh joy, oh bliss!!

thx again, much appreciated.