[BUG_FIXED] Fix the crash issue of window dialog while clicking Sort button without selected item.

Enhance Sort feature GUI part - Enable Sort button only after clicking on the column tab; Disable Sort button after sorting.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository@100 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
donho 2008-01-08 17:36:34 +00:00
parent 72bb63c88d
commit 2ba1a1597f
2 changed files with 11 additions and 1 deletions

View File

@ -167,7 +167,7 @@ END_WINDOW_MAP()
RECT WindowsDlg::_lastKnownLocation; RECT WindowsDlg::_lastKnownLocation;
WindowsDlg::WindowsDlg() : MyBaseClass(WindowsDlgMap) WindowsDlg::WindowsDlg() : MyBaseClass(WindowsDlgMap), _isSorted(false)
{ {
_szMinButton = SIZEZERO; _szMinButton = SIZEZERO;
_szMinListCtrl = SIZEZERO; _szMinListCtrl = SIZEZERO;
@ -218,6 +218,8 @@ BOOL CALLBACK WindowsDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam
case IDC_WINDOWS_SORT: case IDC_WINDOWS_SORT:
doSortToTabs(); doSortToTabs();
_isSorted = false;
updateButtonState();
break; break;
default : default :
@ -318,6 +320,8 @@ BOOL CALLBACK WindowsDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam
for (i=0; i<n; ++i) ListView_SetItemState(_hList, i, sortMap[_idxMap[i]] ? LVIS_SELECTED : 0, LVIS_SELECTED); for (i=0; i<n; ++i) ListView_SetItemState(_hList, i, sortMap[_idxMap[i]] ? LVIS_SELECTED : 0, LVIS_SELECTED);
::InvalidateRect(_hList, &_rc, FALSE); ::InvalidateRect(_hList, &_rc, FALSE);
_isSorted = true;
updateButtonState();
} }
return TRUE; return TRUE;
} }
@ -371,6 +375,7 @@ void WindowsDlg::updateButtonState()
else else
EnableWindow(GetDlgItem(_hSelf, IDOK), FALSE); EnableWindow(GetDlgItem(_hSelf, IDOK), FALSE);
} }
EnableWindow(GetDlgItem(_hSelf, IDC_WINDOWS_SORT), _isSorted);
} }
int WindowsDlg::doDialog(TiXmlNode *dlgNode) int WindowsDlg::doDialog(TiXmlNode *dlgNode)
@ -661,6 +666,10 @@ void WindowsDlg::doClose()
void WindowsDlg::doSortToTabs() void WindowsDlg::doSortToTabs()
{ {
int curSel = ListView_GetNextItem(_hList, -1, LVNI_SELECTED); int curSel = ListView_GetNextItem(_hList, -1, LVNI_SELECTED);
if (curSel == -1)
curSel = 0;
NMWINDLG nmdlg; NMWINDLG nmdlg;
nmdlg.type = WDT_SORT; nmdlg.type = WDT_SORT;
nmdlg.hwndFrom = _hSelf; nmdlg.hwndFrom = _hSelf;

View File

@ -89,6 +89,7 @@ protected :
ScintillaEditView *_pView; ScintillaEditView *_pView;
std::vector<int> _idxMap; std::vector<int> _idxMap;
int _lastSort; int _lastSort;
bool _isSorted;
TiXmlNode *_dlgNode; TiXmlNode *_dlgNode;
private: private: