Add places bar in save as dialog

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@183 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
harrybharry 2008-04-23 20:04:50 +00:00
parent 84fa914ea1
commit cd2cc80ede
9 changed files with 144 additions and 109 deletions

View File

@ -65,7 +65,7 @@ Notepad_plus::Notepad_plus(): Window(), _mainWindowStatus(0), _pDocTab(NULL), _p
{
ZeroMemory(&_prevSelectedRange, sizeof(_prevSelectedRange));
_winVersion = getWindowsVersion();
_winVersion = (NppParameters::getInstance())->getWinVersion();
TiXmlDocument *nativeLangDocRoot = (NppParameters::getInstance())->getNativeLang();
if (nativeLangDocRoot)
@ -8285,91 +8285,3 @@ void Notepad_plus::markSelectedText()
op._isWholeWord = true;
_findReplaceDlg.markAll2(text2Find);
}
typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO);
winVer getWindowsVersion()
{
OSVERSIONINFOEX osvi;
SYSTEM_INFO si;
PGNSI pGNSI;
BOOL bOsVersionInfoEx;
ZeroMemory(&si, sizeof(SYSTEM_INFO));
ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
if( !(bOsVersionInfoEx = GetVersionEx ((OSVERSIONINFO *) &osvi)) )
{
osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
if (! GetVersionEx ( (OSVERSIONINFO *) &osvi) )
return WV_UNKNOWN;
}
pGNSI = (PGNSI) GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "GetNativeSystemInfo");
if(pGNSI != NULL)
pGNSI(&si);
else
GetSystemInfo(&si);
switch (osvi.dwPlatformId)
{
case VER_PLATFORM_WIN32_NT:
{
if ( osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 0 )
{
return WV_VISTA;
}
if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2 )
{
if (osvi.wProductType == VER_NT_WORKSTATION &&
si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64)
{
return WV_XPX64;
}
return WV_S2003;
}
if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 )
return WV_XP;
if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0 )
return WV_W2K;
if ( osvi.dwMajorVersion <= 4 )
return WV_NT;
}
break;
// Test for the Windows Me/98/95.
case VER_PLATFORM_WIN32_WINDOWS:
{
if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 0)
{
return WV_95;
}
if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 10)
{
return WV_98;
}
if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 90)
{
return WV_ME;
}
}
break;
case VER_PLATFORM_WIN32s:
return WV_WIN32S;
default :
return WV_UNKNOWN;
}
return WV_UNKNOWN;
}

View File

@ -65,7 +65,7 @@ const unsigned char TWO_VIEWS_MASK = 2;
const int blockSize = 128 * 1024 + 4;
struct TaskListInfo;
static TiXmlNode * searchDlgNode(TiXmlNode *node, const char *dlgTagName);
static winVer getWindowsVersion();
struct iconLocator {
int listIndex;
int iconIndex;

View File

@ -315,6 +315,91 @@ ScintillaKeyDefinition scintKeyDefs[] = { //array of accelerator keys for all po
//
};
typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO);
winVer getWindowsVersion()
{
OSVERSIONINFOEX osvi;
SYSTEM_INFO si;
PGNSI pGNSI;
BOOL bOsVersionInfoEx;
ZeroMemory(&si, sizeof(SYSTEM_INFO));
ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
if( !(bOsVersionInfoEx = GetVersionEx ((OSVERSIONINFO *) &osvi)) )
{
osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
if (! GetVersionEx ( (OSVERSIONINFO *) &osvi) )
return WV_UNKNOWN;
}
pGNSI = (PGNSI) GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "GetNativeSystemInfo");
if(pGNSI != NULL)
pGNSI(&si);
else
GetSystemInfo(&si);
switch (osvi.dwPlatformId)
{
case VER_PLATFORM_WIN32_NT:
{
if ( osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 0 )
{
return WV_VISTA;
}
if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2 )
{
if (osvi.wProductType == VER_NT_WORKSTATION &&
si.wProcessorArchitecture==PROCESSOR_ARCHITECTURE_AMD64)
{
return WV_XPX64;
}
return WV_S2003;
}
if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 )
return WV_XP;
if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0 )
return WV_W2K;
if ( osvi.dwMajorVersion <= 4 )
return WV_NT;
}
break;
// Test for the Windows Me/98/95.
case VER_PLATFORM_WIN32_WINDOWS:
{
if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 0)
{
return WV_95;
}
if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 10)
{
return WV_98;
}
if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 90)
{
return WV_ME;
}
}
break;
case VER_PLATFORM_WIN32s:
return WV_WIN32S;
default :
return WV_UNKNOWN;
}
return WV_UNKNOWN;
}
NppParameters * NppParameters::_pSelf = new NppParameters;
@ -326,6 +411,9 @@ NppParameters::NppParameters() : _pXmlDoc(NULL),_pXmlUserDoc(NULL), _pXmlUserSty
_transparentFuncAddr(NULL), _enableThemeDialogTextureFuncAddr(NULL),\
_isTaskListRBUTTONUP_Active(false), _fileSaveDlgFilterIndex(-1), _asNotepadStyle(false)
{
//Get windows version
_winVersion = getWindowsVersion();
// Prepare for default path
char nppPath[MAX_PATH];
::GetModuleFileName(NULL, nppPath, sizeof(nppPath));
@ -4091,8 +4179,3 @@ void NppParameters::addScintillaModifiedIndex(int index)
_scintillaModifiedKeyIndices.push_back(index);
}
}

View File

@ -1071,6 +1071,8 @@ public:
bool reloadPluginCmds() {
return getPluginCmdsFromXmlTree();
}
winVer getWinVersion() { return _winVersion; };
private:
NppParameters();
~NppParameters();
@ -1141,6 +1143,8 @@ private:
FindDlgTabTitiles _findDlgTabTitiles;
bool _asNotepadStyle;
winVer _winVersion;
static int CALLBACK EnumFontFamExProc(ENUMLOGFONTEX *lpelfe, NEWTEXTMETRICEX *lpntme, int FontType, LPARAM lParam) {
vector<string> *pStrVect = (vector<string> *)lParam;
size_t vectSize = pStrVect->size();

View File

@ -177,7 +177,7 @@ public :
_line = new char[_maxNbCharAllocated + 3];
_uniCharLine = new char[(_maxNbCharAllocated + 3) * 2];
_uniFileName = new char[(_fileNameLenMax + 3) * 2];
_winVer = (winVer)::SendMessage(_hParent, NPPM_GETWINDOWSVERSION, 0, 0);
_winVer = (NppParameters::getInstance())->getWinVersion();
//strcpy(_findAllResultStr, FIND_RESULT_DEFAULT_TITLE);
};
~FindReplaceDlg() {

View File

@ -273,7 +273,7 @@ void Gripper::create(void)
::MessageBox(NULL, str, "SetWindowsHookEx(MOUSE) failed", MB_OK | MB_ICONERROR);
}
winVer winVersion = (winVer)::SendMessage(_hParent, NPPM_GETWINDOWSVERSION, 0, 0);
winVer winVersion = (NppParameters::getInstance())->getWinVersion();
if (winVersion < WV_VISTA)
{
hookKeyboard = ::SetWindowsHookEx(WH_KEYBOARD, (HOOKPROC)hookProcKeyboard, _hInst, 0);

View File

@ -19,17 +19,23 @@
FileDialog *FileDialog::staticThis = NULL;
int FileDialog::_dialogFileBoxId = (NppParameters::getInstance())->getWinVersion() < WV_W2K?edt1:cmb13;
FileDialog::FileDialog(HWND hwnd, HINSTANCE hInst)
: _nbCharFileExt(0), _nbExt(0)
{staticThis = this;
{
staticThis = this;
for (int i = 0 ; i < nbExtMax ; i++)
_extArray[i][0] = '\0';
memset(_fileExt, 0x00, sizeof(_fileExt));
_fileName[0] = '\0';
_winVersion = (NppParameters::getInstance())->getWinVersion();
_ofn.lStructSize = sizeof(_ofn);
if (_winVersion < WV_W2K)
_ofn.lStructSize = sizeof(OPENFILENAME);
_ofn.hwndOwner = hwnd;
_ofn.hInstance = hInst;
_ofn.lpstrFilter = _fileExt;
@ -48,9 +54,9 @@ FileDialog::FileDialog(HWND hwnd, HINSTANCE hInst)
_ofn.lpstrDefExt = NULL; // No default extension
_ofn.lCustData = 0;
_ofn.Flags = OFN_PATHMUSTEXIST | OFN_EXPLORER | OFN_LONGNAMES | DS_CENTER | OFN_HIDEREADONLY;
//_ofn.pvReserved = NULL;
//_ofn.dwReserved = 0;
//_ofn.FlagsEx = 0;
_ofn.pvReserved = NULL;
_ofn.dwReserved = 0;
_ofn.FlagsEx = 0;
}
// This function set and concatenate the filter into the list box of FileDialog.
@ -137,7 +143,7 @@ char * FileDialog::doOpenSingleFileDlg()
char *fn = NULL;
try {
fn = ::GetOpenFileName(&_ofn)?_fileName:NULL;
fn = ::GetOpenFileName((OPENFILENAME*)&_ofn)?_fileName:NULL;
}
catch(...) {
::MessageBox(NULL, "GetSaveFileName crashes!!!", "", MB_OK);
@ -153,7 +159,7 @@ stringVector * FileDialog::doOpenMultiFilesDlg()
_ofn.Flags |= OFN_FILEMUSTEXIST | OFN_ALLOWMULTISELECT;
if (::GetOpenFileName(&_ofn))
if (::GetOpenFileName((OPENFILENAME*)&_ofn))
{
char fn[MAX_PATH];
char *pFn = _fileName + strlen(_fileName) + 1;
@ -195,7 +201,7 @@ char * FileDialog::doSaveDlg()
char *fn = NULL;
try {
fn = ::GetSaveFileName(&_ofn)?_fileName:NULL;
fn = ::GetSaveFileName((OPENFILENAME*)&_ofn)?_fileName:NULL;
}
catch(...) {
::MessageBox(NULL, "GetSaveFileName crashes!!!", "", MB_OK);
@ -216,7 +222,7 @@ static BOOL CALLBACK fileDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM
{
case IDOK :
{
HWND fnControl = ::GetDlgItem(hwnd, edt1);
HWND fnControl = ::GetDlgItem(hwnd, FileDialog::_dialogFileBoxId);
char fn[256];
::GetWindowText(fnControl, fn, sizeof(fn));
if (*fn == '\0')
@ -317,7 +323,7 @@ BOOL APIENTRY FileDialog::run(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam
{
case CDN_TYPECHANGE :
{
HWND fnControl = ::GetDlgItem(::GetParent(hWnd), edt1);
HWND fnControl = ::GetDlgItem(::GetParent(hWnd), _dialogFileBoxId);
HWND typeControl = ::GetDlgItem(::GetParent(hWnd), cmb1);
currentExt = addExt(fnControl, typeControl);
return TRUE;

View File

@ -36,6 +36,32 @@ typedef vector<string> stringVector;
//const bool styleOpen = true;
//const bool styleSave = false;
struct OPENFILENAMENPP {
DWORD lStructSize;
HWND hwndOwner;
HINSTANCE hInstance;
LPCTSTR lpstrFilter;
LPTSTR lpstrCustomFilter;
DWORD nMaxCustFilter;
DWORD nFilterIndex;
LPTSTR lpstrFile;
DWORD nMaxFile;
LPTSTR lpstrFileTitle;
DWORD nMaxFileTitle;
LPCTSTR lpstrInitialDir;
LPCTSTR lpstrTitle;
DWORD Flags;
WORD nFileOffset;
WORD nFileExtension;
LPCTSTR lpstrDefExt;
LPARAM lCustData;
LPOFNHOOKPROC lpfnHook;
LPCTSTR lpTemplateName;
void * pvReserved;
DWORD dwReserved;
DWORD FlagsEx;
};
static string changeExt(string fn, string ext)
{
@ -100,6 +126,7 @@ public:
char * doOpenSingleFileDlg();
bool isReadOnly() {return _ofn.Flags & OFN_READONLY;};
static int _dialogFileBoxId;
protected :
static UINT APIENTRY OFNHookProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
BOOL APIENTRY run(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
@ -111,7 +138,10 @@ private:
int _nbCharFileExt;
stringVector _fileNames;
OPENFILENAME _ofn;
OPENFILENAMENPP _ofn;
winVer _winVersion;
char _extArray[nbExtMax][extLenMax];
int _nbExt;

View File

@ -112,7 +112,7 @@ protected :
#ifndef WH_MOUSE_LL
#define WH_MOUSE_LL 14
#endif
winVer ver = (winVer)::SendMessage(_hParent, NPPM_GETWINDOWSVERSION, 0, 0);
winVer ver = (NppParameters::getInstance())->getWinVersion();
_hHooker = ::SetWindowsHookEx(ver >= WV_W2K?WH_MOUSE_LL:WH_MOUSE, (HOOKPROC)hookProc, _hInst, 0);
hook = _hHooker;
return FALSE;