Copy detail view contents on CTRL-C (removed the popup context menu approach since it wasn't language independent). This code sucks, please improve it :)
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@841 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
1518061acf
commit
88d1eb693f
1 changed files with 38 additions and 49 deletions
|
@ -1405,61 +1405,50 @@ static BOOL CALLBACK InstProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//>>>Ximon Eighteen aka Sunjammer 30th August 2002
|
//>>>Ximon Eighteen aka Sunjammer 30th August 2002
|
||||||
//+++Popup "Copy Details To Clipboard" menu when RMB clicked in DetailView
|
//+++If CTRL-C is pressed (yeah I know this has got to be the most stupid
|
||||||
//+++Currently this has no language support for the popup menu text, I'm
|
//+++way to test for this) copy the DetailPrint'd strings to the clipboard.
|
||||||
//+++looking to possibly change this code to work off CTRL-C instead of a
|
if (uMsg == WM_NOTIFY && ((NMHDR*)lParam)->code == LVN_KEYDOWN &&
|
||||||
//+++popup menu to avoid the language problem.
|
((VK_CONTROL == ((NMLVKEYDOWN*)lParam)->wVKey && GetKeyState('C') == -127) ||
|
||||||
if (uMsg == WM_NOTIFY && ((NMHDR*)lParam)->code == NM_RCLICK)
|
('C' == ((NMLVKEYDOWN*)lParam)->wVKey && GetKeyState(VK_CONTROL) == -127)))
|
||||||
{
|
{
|
||||||
int count = ListView_GetItemCount(insthwnd);
|
int count = ListView_GetItemCount(insthwnd);
|
||||||
if (count > 0)
|
if (count > 0)
|
||||||
{
|
{
|
||||||
DWORD pos = GetMessagePos();
|
char textBuf[1024];
|
||||||
HMENU menu = CreatePopupMenu();
|
int i,total = 0;
|
||||||
AppendMenu(menu,MF_STRING,1,"Copy Details To Clipboard");
|
LVITEM item;
|
||||||
if (1==TrackPopupMenu(
|
HGLOBAL memory;
|
||||||
menu,
|
LPTSTR ptr,endPtr;
|
||||||
TPM_NONOTIFY|TPM_RETURNCMD,
|
|
||||||
GET_X_LPARAM(pos),
|
// 1st pass - determine clipboard memory required.
|
||||||
GET_Y_LPARAM(pos),
|
item.iSubItem = 0;
|
||||||
0,insthwnd,0))
|
item.pszText = textBuf;
|
||||||
|
item.cchTextMax = 1023;
|
||||||
|
for (i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
char textBuf[1024];
|
// Add 2 for the CR/LF combination that must follow every line.
|
||||||
int i,total = 0;
|
total += 2+SendMessage(insthwnd,LVM_GETITEMTEXT,i,(LPARAM)&item);
|
||||||
LVITEM item;
|
|
||||||
HGLOBAL memory;
|
|
||||||
LPTSTR ptr,endPtr;
|
|
||||||
|
|
||||||
// 1st pass - determine clipboard memory required.
|
|
||||||
item.iSubItem = 0;
|
|
||||||
item.pszText = textBuf;
|
|
||||||
item.cchTextMax = 1023;
|
|
||||||
for (i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
// Add 2 for the CR/LF combination that must follow every line.
|
|
||||||
total += 2+SendMessage(insthwnd,LVM_GETITEMTEXT,i,(LPARAM)&item);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2nd pass - store detail view strings on the clipboard
|
|
||||||
// Clipboard MSDN docs say mem must be GMEM_MOVEABLE
|
|
||||||
OpenClipboard(0);
|
|
||||||
EmptyClipboard();
|
|
||||||
memory = GlobalAlloc(GMEM_MOVEABLE,total+1);
|
|
||||||
ptr = GlobalLock(memory);
|
|
||||||
endPtr = ptr+total;
|
|
||||||
for (i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
// -2 to allow for CR/LF
|
|
||||||
ListView_GetItemText(insthwnd,i,0,ptr,(endPtr-2)-ptr);
|
|
||||||
while (*ptr) ptr++;
|
|
||||||
*ptr++ = '\r';
|
|
||||||
*ptr++ = '\n';
|
|
||||||
}
|
|
||||||
*ptr++ = 0;
|
|
||||||
GlobalUnlock(memory);
|
|
||||||
SetClipboardData(CF_TEXT,memory);
|
|
||||||
CloseClipboard();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 2nd pass - store detail view strings on the clipboard
|
||||||
|
// Clipboard MSDN docs say mem must be GMEM_MOVEABLE
|
||||||
|
OpenClipboard(0);
|
||||||
|
EmptyClipboard();
|
||||||
|
memory = GlobalAlloc(GMEM_MOVEABLE,total+1);
|
||||||
|
ptr = GlobalLock(memory);
|
||||||
|
endPtr = ptr+total;
|
||||||
|
for (i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
// -2 to allow for CR/LF
|
||||||
|
ListView_GetItemText(insthwnd,i,0,ptr,(endPtr-2)-ptr);
|
||||||
|
while (*ptr) ptr++;
|
||||||
|
*ptr++ = '\r';
|
||||||
|
*ptr++ = '\n';
|
||||||
|
}
|
||||||
|
*ptr++ = 0;
|
||||||
|
GlobalUnlock(memory);
|
||||||
|
SetClipboardData(CF_TEXT,memory);
|
||||||
|
CloseClipboard();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//<<<
|
//<<<
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue