From 681bb5943ac1f08bdd58020c8d90420f5ef39965 Mon Sep 17 00:00:00 2001 From: donho Date: Sat, 20 Oct 2007 14:10:42 +0000 Subject: [PATCH] [ENHANCEMENT] New auto-add extension behaviour : the chosen filter is remembered on the next launch. git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@56 f5eea248-9336-0410-98b8-ebc06183d4e3 --- PowerEditor/src/Parameters.cpp | 2 +- PowerEditor/src/Parameters.h | 5 ++++ .../OpenSaveFileDialog/FileDialog.cpp | 25 +++++++++++++++---- .../OpenSaveFileDialog/FileDialog.h | 2 +- 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index a31359af6..f6c42f5a3 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -30,7 +30,7 @@ NppParameters::NppParameters() : _pXmlDoc(NULL),_pXmlUserDoc(NULL), _pXmlUserSty _pXmlShortcutDoc(NULL), _pXmlContextMenuDoc(NULL), _pXmlSessionDoc(NULL),\ _nbUserLang(0), _hUser32(NULL), _hUXTheme(NULL),\ _transparentFuncAddr(NULL), _enableThemeDialogTextureFuncAddr(NULL),\ - _isTaskListRBUTTONUP_Active(false) + _isTaskListRBUTTONUP_Active(false), _fileSaveDlgFilterIndex(-1) { _appdataNppDir[0] = '\0'; } diff --git a/PowerEditor/src/Parameters.h b/PowerEditor/src/Parameters.h index e22654669..6dfbfc641 100644 --- a/PowerEditor/src/Parameters.h +++ b/PowerEditor/src/Parameters.h @@ -895,6 +895,9 @@ public: void setIsNoPlugin(bool noPlugin) {_noPlugin = noPlugin;}; bool isNoPlugin() const {return _noPlugin;}; + void setFileSaveDlgFilterIndex(int ln) {_fileSaveDlgFilterIndex = ln;}; + int getFileSaveDlgFilterIndex() const {return _fileSaveDlgFilterIndex;}; + bool isRemappingShortcut() const {return _shortcuts.size() != 0;}; vector & getUserShortcuts() {return _shortcuts;}; @@ -1004,6 +1007,8 @@ private: int _lineNumber2Go; bool _noPlugin; + int _fileSaveDlgFilterIndex; + // All Styles (colours & fonts) LexerStylerArray _lexerStylerArray; StyleArray _widgetStyleArray; diff --git a/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.cpp b/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.cpp index a19d51e0f..a9dc3703b 100644 --- a/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.cpp +++ b/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.cpp @@ -271,16 +271,20 @@ UINT_PTR CALLBACK FileDialog::OFNHookProc(HWND hWnd, UINT uMsg, WPARAM wParam, L { case WM_INITDIALOG : { + NppParameters *pNppParam = NppParameters::getInstance(); + int index = pNppParam->getFileSaveDlgFilterIndex(); + ::SetWindowLong(hWnd, GWL_USERDATA, (long)staticThis); hFileDlg = ::GetParent(hWnd); goToCenter(hFileDlg); - /*if (staticThis->_initIndex != -1) + if (index != -1) { HWND typeControl = ::GetDlgItem(hFileDlg, cmb1); - ::SendMessage(typeControl, CB_SETCURSEL, staticThis->_initIndex, 0); - HWND fnControl = ::GetDlgItem(hFileDlg, edt1); - currentExt = addExt(fnControl, typeControl); - }*/ + + ::SendMessage(typeControl, CB_SETCURSEL, index, 0); + //HWND fnControl = ::GetDlgItem(hFileDlg, edt1); + //currentExt = addExt(fnControl, typeControl); + } oldProc = (WNDPROC)::SetWindowLong(hFileDlg, GWL_WNDPROC, (LONG)fileDlgProc); return FALSE; } @@ -295,6 +299,7 @@ UINT_PTR CALLBACK FileDialog::OFNHookProc(HWND hWnd, UINT uMsg, WPARAM wParam, L } return FALSE; } + BOOL APIENTRY FileDialog::run(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) @@ -312,6 +317,16 @@ BOOL APIENTRY FileDialog::run(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam break; } + + case CDN_FILEOK : + { + HWND typeControl = ::GetDlgItem(::GetParent(hWnd), cmb1); + int index = ::SendMessage(typeControl, CB_GETCURSEL, 0, 0); + NppParameters *pNppParam = NppParameters::getInstance(); + pNppParam->setFileSaveDlgFilterIndex(index); + break; + } + default : return FALSE; } diff --git a/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.h b/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.h index 5dc99b273..f6f03af1c 100644 --- a/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.h +++ b/PowerEditor/src/WinControls/OpenSaveFileDialog/FileDialog.h @@ -25,6 +25,7 @@ #include #include #include "SysMsg.h" +#include "Parameters.h" const int nbExtMax = 256; const int extLenMax = 64; @@ -105,7 +106,6 @@ private: char _extArray[nbExtMax][extLenMax]; int _nbExt; - //int _initIndex; static FileDialog *staticThis; };