From 117136e3418fef8c0025e4785d1c38f37a5fe76d Mon Sep 17 00:00:00 2001 From: Don Ho Date: Sun, 6 Nov 2011 16:44:39 +0000 Subject: [PATCH] [BUG_FIXED] Fix a crash issue while right-clicking on the doc switcher's column control ("Name" and "Ext."). git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@840 f5eea248-9336-0410-98b8-ebc06183d4e3 --- .../VerticalFileSwitcher/VerticalFileSwitcher.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcher.cpp b/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcher.cpp index 8d8de4b8f..3d76f54fd 100644 --- a/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcher.cpp +++ b/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcher.cpp @@ -66,10 +66,8 @@ BOOL CALLBACK VerticalFileSwitcher::run_dlgProc(UINT message, WPARAM wParam, LPA { LPNMITEMACTIVATE lpnmitem = (LPNMITEMACTIVATE) lParam; int i = lpnmitem->iItem; - if (i == -1) { - //::MessageBoxA(NULL, "oh yeh","",MB_OK); ::SendMessage(_hParent, WM_COMMAND, IDM_FILE_NEW, 0); } return TRUE; @@ -78,9 +76,9 @@ BOOL CALLBACK VerticalFileSwitcher::run_dlgProc(UINT message, WPARAM wParam, LPA case NM_CLICK: { LPNMITEMACTIVATE lpnmitem = (LPNMITEMACTIVATE) lParam; + int nbItem = ListView_GetItemCount(_fileListView.getHSelf()); int i = lpnmitem->iItem; - - if (i == -1) + if (i == -1 || i >= nbItem) return TRUE; LVITEM item; @@ -97,9 +95,10 @@ BOOL CALLBACK VerticalFileSwitcher::run_dlgProc(UINT message, WPARAM wParam, LPA { // Switch to the right document LPNMITEMACTIVATE lpnmitem = (LPNMITEMACTIVATE) lParam; + int nbItem = ListView_GetItemCount(_fileListView.getHSelf()); int i = lpnmitem->iItem; - if (i == -1) - return TRUE; + if (i == -1 || i >= nbItem) + return TRUE; LVITEM item; item.mask = LVIF_PARAM; @@ -143,7 +142,6 @@ BOOL CALLBACK VerticalFileSwitcher::run_dlgProc(UINT message, WPARAM wParam, LPA case VK_RETURN: { int i = ListView_GetSelectionMark(_fileListView.getHSelf()); - if (i == -1) return TRUE;