tags:

views:

452

answers:

3

Using GetSaveFileName. I specify the OFN_EXPLORER flag, but I always get old dialog appearance unless I avoid using both hook and template. (lpfnHook and lpfnTemplate (and their respective "enable" flags) in OPENFILENAME structure)

If I avoid using just one or the other, I still get the old dialog appearance. I also tried no template, but use the hook... but always return TRUE from it (I saw mention of "always returning false" from the hook as a way to GET the old interface). It didn't seem to have any effect, though.

EDIT: Added relevant code:

ofn.lStructSize=sizeof(OPENFILENAME);
ofn.hInstance=RhInst;
ofn.hwndOwner=MainWh;
ofn.lpstrFilter=s;
ofn.lpstrCustomFilter=null;
ofn.nMaxCustFilter=0;
ofn.nFilterIndex=sel;

ofn.lpstrFile=fname;
ofn.nMaxFile=lstrl;
ofn.lpstrFileTitle=tfile;
ofn.nMaxFileTitle=lstrl;

if (path && lstrlen(path)) ofn.lpstrInitialDir=path;
else ofn.lpstrInitialDir=drive;

lstrcpy(SE_DefExt,ext);
ofn.lpstrDefExt=SE_DefExt;
if (titleid) ofn.lpstrTitle=title;
else ofn.lpstrTitle=null;

ofn.lpfnHook=(CommHookProc)MakeProcInstance((FARPROC)SEOpen32Hook,hInst);
ofn.lpTemplateName=NULL;
ofn.Flags=OFN_SHOWHELP | OFN_OVERWRITEPROMPT | OFN_ENABLEHOOK  | OFN_EXPLORER
   | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY;

if(allowfit)
    {
    ofn.lpTemplateName = MAKEINTRESOURCE(SAVETOFIT);
    ofn.Flags |= OFN_ENABLETEMPLATE;
    }

if (GetSaveFileName(&ofn))
    {
    // <snip>
    }

Note that "allowfit" is non-zero/true in this case. If I comment out the setting of the flag for both OFN_ENABLEHOOK and OFN_ENABLETEMPLATE, I get the "new" dialog appearance.

**EDIT 2:
It looks now like I was confused on what I was seeing. I believe in both cases, I'm getting the "new" OFN_EXPLORER behavior and appearance. When I remove the OFN_EXPLORER flag, I get a very old style dialog box.

What I am trying to get to is the style of Save File dialog that has the Back and Forward button in the upper right, and (most importantly) an address box that I can type in. All my previous comments and code descriptions (above) still apply; when I remove the Template and the Hook, I get my "back & forward" buttons, and my typeable address box (plus left-side browse tree)... when I leave the template and the hook in place -- I do not (instead has "Save in" picklist at top, and "standard places" along the left ("Recent places", "Desktop", ...).

A: 

Perhaps you need to show some code? According to MSDN:

You can provide an OFNHookProc hook procedure for an Explorer-style Save dialog box. To enable the hook procedure, set the OFN_EXPLORER and OFN_ENABLEHOOK flags in the Flags member of the OPENFILENAME structure and specify the address of the hook procedure in the lpfnHook member.

So it seems like unless you are doing something weird, it should work.

flodin
A: 

As for the template, You should define DS_SHELLFONT. http://blogs.msdn.com/oldnewthing/archive/2005/02/04/366987.aspx

See my "Edit 2" above. It looks like I'm not fighting "old look/new look" as set by OFN_EXPLORER, I'm fighting some browser/non-browser behavior and appearance. Any idea what I might need to do? Sadly, I can't just remove my template and hook; those must stay.
Steve
+1  A: 

did you define _WIN32_WINNT >= 0x0500? Setting lStructSize to the win2000 size might help the dialog decide (If you need to support < NT5 you would have to do some version checking and use OPENFILENAME_SIZE_VERSION_400 as the size on down-level systems)

Anders