Originally Posted by
Stoned_Coder
it should be enough if you add a value NoPlacesBar to this key...
HKEY_CURRENT_USER\Software\Microsoft\Windows\Curre ntVersion\Policies\Comdlg32
I believe that's a global setting. There is a couple of instance specific options:
Code:
#define _WIN32_WINNT 0x0500
#include <windows.h>
#include <stdio.h>
#pragma comment(lib, "comdlg32.lib")
/*
* Control, with places bar.
*/
BOOL DoFileOpen(HWND hwnd, LPTSTR szFile, DWORD cchFile)
{
OPENFILENAME ofn = { 0 };
if (cchFile != 0)
{
szFile[0] = TEXT('\0');
}
ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
ofn.hwndOwner = hwnd;
ofn.lpstrFilter = TEXT("All Files (*.*)\0*.*\0");
ofn.lpstrFile = szFile;
ofn.nMaxFile = cchFile;
ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST;
ofn.lpstrDefExt = NULL;
return GetOpenFileName(&ofn);
}
/*
* No places bar, should work on all versions of Windows.
*/
BOOL DoFileOpenNoPlaces1(HWND hwnd, LPTSTR szFile, DWORD cchFile)
{
OPENFILENAME ofn = { 0 };
if (cchFile != 0)
{
szFile[0] = TEXT('\0');
}
ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
ofn.hwndOwner = hwnd;
ofn.lpstrFilter = TEXT("All Files (*.*)\0*.*\0");
ofn.lpstrFile = szFile;
ofn.nMaxFile = cchFile;
ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_ENABLEHOOK;
ofn.lpstrDefExt = NULL;
return GetOpenFileName(&ofn);
}
/*
* No places bar, will only work on 2000/XP
*/
BOOL DoFileOpenNoPlaces2(HWND hwnd, LPTSTR szFile, DWORD cchFile)
{
OPENFILENAME ofn = { 0 };
if (cchFile != 0)
{
szFile[0] = TEXT('\0');
}
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hwnd;
ofn.lpstrFilter = TEXT("All Files (*.*)\0*.*\0");
ofn.lpstrFile = szFile;
ofn.nMaxFile = cchFile;
ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST;
ofn.lpstrDefExt = NULL;
ofn.FlagsEx = OFN_EX_NOPLACESBAR;
return GetOpenFileName(&ofn);
}
int main(void)
{
TCHAR szFileName[MAX_PATH];
DoFileOpen(NULL, szFileName, MAX_PATH);
printf("File = %s\n", szFileName);
DoFileOpenNoPlaces1(NULL, szFileName, MAX_PATH);
printf("File = %s\n", szFileName);
DoFileOpenNoPlaces2(NULL, szFileName, MAX_PATH);
printf("File = %s\n", szFileName);
getchar();
return 0;
}