[BUG_FIXED] Fix ANSI version Clipboard history entries display bug.

git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@798 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
Don Ho 2011-08-21 21:34:19 +00:00
parent df3e1d4ef8
commit bcb9206c43
2 changed files with 30 additions and 24 deletions

View File

@ -22,23 +22,22 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include "ScintillaEditView.h" #include "ScintillaEditView.h"
#include "clipboardFormats.h" #include "clipboardFormats.h"
/* #ifdef UNICODE
void ClipboardHistoryPanel::switchEncoding() #define CLIPBOARD_TEXTFORMAT CF_UNICODETEXT
{ #else
//int codepage = (*_ppEditView)->getCurrentBuffer()->getEncoding(); #define CLIPBOARD_TEXTFORMAT CF_TEXT
} #endif
*/
ClipboardData ClipboardHistoryPanel::getClipboadData() ClipboardData ClipboardHistoryPanel::getClipboadData()
{ {
ClipboardData clipboardData; ClipboardData clipboardData;
if (!IsClipboardFormatAvailable(CF_UNICODETEXT)) if (!IsClipboardFormatAvailable(CLIPBOARD_TEXTFORMAT))
return clipboardData; return clipboardData;
if (!OpenClipboard(NULL)) if (!OpenClipboard(NULL))
return clipboardData; return clipboardData;
HGLOBAL hglb = GetClipboardData(CF_UNICODETEXT); HGLOBAL hglb = GetClipboardData(CLIPBOARD_TEXTFORMAT);
if (hglb != NULL) if (hglb != NULL)
{ {
char *lpchar = (char *)GlobalLock(hglb); char *lpchar = (char *)GlobalLock(hglb);
@ -213,6 +212,7 @@ BOOL CALLBACK ClipboardHistoryPanel::run_dlgProc(UINT message, WPARAM wParam, LP
int i = ::SendDlgItemMessage(_hSelf, IDC_LIST_CLIPBOARD, LB_GETCURSEL, 0, 0); int i = ::SendDlgItemMessage(_hSelf, IDC_LIST_CLIPBOARD, LB_GETCURSEL, 0, 0);
if (i != LB_ERR) if (i != LB_ERR)
{ {
#ifdef UNICODE
int codepage = (*_ppEditView)->getCurrentBuffer()->getEncoding(); int codepage = (*_ppEditView)->getCurrentBuffer()->getEncoding();
if (codepage == -1) if (codepage == -1)
{ {
@ -233,6 +233,14 @@ BOOL CALLBACK ClipboardHistoryPanel::run_dlgProc(UINT message, WPARAM wParam, LP
(*_ppEditView)->execute(SCI_ADDTEXT, strlen(c), (LPARAM)c); (*_ppEditView)->execute(SCI_ADDTEXT, strlen(c), (LPARAM)c);
(*_ppEditView)->getFocus(); (*_ppEditView)->getFocus();
delete [] c; delete [] c;
#else
ByteArray ba(_clipboardDataVector[i]);
char *str = (char *)ba.getPointer();
(*_ppEditView)->execute(SCI_REPLACESEL, 0, (LPARAM)"");
(*_ppEditView)->execute(SCI_ADDTEXT, strlen(str), (LPARAM)str);
(*_ppEditView)->getFocus();
#endif
} }
} }
return TRUE; return TRUE;

View File

@ -23,26 +23,24 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
int CALLBACK ListViewCompareProc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort) int CALLBACK ListViewCompareProc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{ {
int result; LPNMLISTVIEW pnmListView = (LPNMLISTVIEW)lParamSort;
TCHAR str1[MAX_PATH];
TCHAR str2[MAX_PATH];
ListView_GetItemText(pnmListView->hdr.hwndFrom, lParam1, pnmListView->iSubItem, str1, sizeof(str1));
ListView_GetItemText(pnmListView->hdr.hwndFrom, lParam2, pnmListView->iSubItem, str2, sizeof(str2));
LVCOLUMN lvc; LVCOLUMN lvc;
BOOL is_direction_up;
LPNMLISTVIEW pnm_list_view = (LPNMLISTVIEW)lParamSort;
TCHAR str1[2048];
TCHAR str2[2048];
ListView_GetItemText(pnm_list_view->hdr.hwndFrom, lParam1, pnm_list_view->iSubItem, str1, sizeof(str1));
ListView_GetItemText(pnm_list_view->hdr.hwndFrom, lParam2, pnm_list_view->iSubItem, str2, sizeof(str2));
lvc.mask = LVCF_FMT; lvc.mask = LVCF_FMT;
SendMessage(pnm_list_view->hdr.hwndFrom, LVM_GETCOLUMN, (WPARAM)pnm_list_view->iSubItem, (LPARAM)&lvc); ::SendMessage(pnmListView->hdr.hwndFrom, LVM_GETCOLUMN, (WPARAM)pnmListView->iSubItem, (LPARAM)&lvc);
is_direction_up = (HDF_SORTUP & lvc.fmt); bool isDirectionUp = (HDF_SORTUP & lvc.fmt) != 0;
result = lstrcmp(str1, str2); int result = lstrcmp(str1, str2);
if(is_direction_up) if (isDirectionUp)
result = 0 - result; return result;
return(result); return (0 - result);
}; };
BOOL CALLBACK VerticalFileSwitcher::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) BOOL CALLBACK VerticalFileSwitcher::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)