From d0b5caf64e6a01112a8fce4b93340fb0cb88edbe Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 18 Oct 2018 21:50:13 +0300 Subject: fixes #1622 (Add ability to copy text from Import log) --- plugins/Import/res/resource.rc | 15 ++++++++++++++- plugins/Import/src/progress.cpp | 39 +++++++++++++++++++++++++++++++++++++++ plugins/Import/src/resource.h | 8 +++++--- plugins/Import/src/stdafx.h | 1 + 4 files changed, 59 insertions(+), 4 deletions(-) (limited to 'plugins/Import') diff --git a/plugins/Import/res/resource.rc b/plugins/Import/res/resource.rc index a7aa1f2a17..dc2ed1fac5 100644 --- a/plugins/Import/res/resource.rc +++ b/plugins/Import/res/resource.rc @@ -246,7 +246,6 @@ LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT IDD_IMPORT_CONTACT DIALOGEX 0, 0, 361, 76 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_APPWINDOW -CAPTION "" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN DEFPUSHBUTTON "OK",IDOK,247,55,50,14 @@ -287,6 +286,20 @@ BEGIN 0 END + +///////////////////////////////////////////////////////////////////////////// +// +// Menu +// + +IDR_LIST MENU +BEGIN + POPUP "Context1" + BEGIN + MENUITEM "Copy", IDM_COPY + END +END + #endif // Russian (Russia) resources ///////////////////////////////////////////////////////////////////////////// diff --git a/plugins/Import/src/progress.cpp b/plugins/Import/src/progress.cpp index 87b89a76ea..434f072bd6 100644 --- a/plugins/Import/src/progress.cpp +++ b/plugins/Import/src/progress.cpp @@ -33,6 +33,8 @@ CProgressPageDlg::CProgressPageDlg() : m_list(this, IDC_STATUS), m_timer(this, 1) { + m_list.OnBuildMenu = Callback(this, &CProgressPageDlg::OnContextMenu); + m_timer.OnEvent = Callback(this, &CProgressPageDlg::OnTimer); } @@ -57,6 +59,43 @@ void CProgressPageDlg::OnNext() PostMessage(m_hwndParent, WIZM_GOTOPAGE, 0, (LPARAM)new CFinishedPageDlg()); } +void CProgressPageDlg::OnContextMenu(CCtrlBase*) +{ + POINT pt; + ::GetCursorPos(&pt); + + HMENU hMenu = ::LoadMenu(g_plugin.getInst(), MAKEINTRESOURCE(IDR_LIST)); + switch (::TrackPopupMenu(GetSubMenu(hMenu, 0), TPM_RETURNCMD, pt.x, pt.y, 0, m_hwnd, nullptr)) { + case IDM_COPY: + CMStringW wszText; + int nLines = m_list.GetCount(); + for (int i = 0; i < nLines; i++) { + ptrW wszLine(m_list.GetItemText(i)); + if (wszLine) { + wszText.Append(wszLine); + wszText.Append(L"\r\n"); + } + } + if (wszText.IsEmpty()) + break; + + if (::OpenClipboard(m_hwnd)) { + size_t i = sizeof(wchar_t) * (wszText.GetLength() + 1); + + ::EmptyClipboard(); + HGLOBAL hData = ::GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE, i); + + memcpy((void*)::GlobalLock(hData), wszText, i); + ::GlobalUnlock(hData); + ::SetClipboardData(CF_UNICODETEXT, hData); + ::CloseClipboard(); + } + break; + } + + ::DestroyMenu(hMenu); +} + void CProgressPageDlg::OnTimer(CTimer*) { m_timer.Stop(); diff --git a/plugins/Import/src/resource.h b/plugins/Import/src/resource.h index 7857ea0834..f75f1d2a15 100644 --- a/plugins/Import/src/resource.h +++ b/plugins/Import/src/resource.h @@ -14,7 +14,8 @@ #define IDD_MIRANDADB 110 #define IDD_PROGRESS 111 #define IDD_ADVOPTIONS 112 -#define IDI_IMPORT 177 +#define IDR_LIST 113 +#define IDI_IMPORT 114 #define IDC_DONTLOADPLUGIN 1001 #define IDC_MIRANDA 1002 #define IDC_OTHER 1005 @@ -51,14 +52,15 @@ #define IDC_FT 1040 #define IDC_OPEN_FILE 1042 #define IDC_CHECK_DUPS 1043 +#define IDM_COPY 40001 #define IDC_STATIC -1 // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 111 -#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_RESOURCE_VALUE 115 +#define _APS_NEXT_COMMAND_VALUE 40002 #define _APS_NEXT_CONTROL_VALUE 1044 #define _APS_NEXT_SYMED_VALUE 101 #endif diff --git a/plugins/Import/src/stdafx.h b/plugins/Import/src/stdafx.h index 06c0454843..c30d02c3b0 100644 --- a/plugins/Import/src/stdafx.h +++ b/plugins/Import/src/stdafx.h @@ -115,6 +115,7 @@ public: void OnNext() override; void OnTimer(CTimer*); + void OnContextMenu(CCtrlBase*); void AddMessage(const wchar_t *pMsg); void SetProgress(int); -- cgit v1.2.3