Official eMule-Board: [patch] Copy Statistics To Clipboard - Official eMule-Board

Jump to content


Page 1 of 1

[patch] Copy Statistics To Clipboard as seen in enkeyDEV.5 mod

#1 User is offline   kei-kun 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 10
  • Joined: 26-December 02

Posted 30 March 2003 - 11:21 PM

This add the possibility to copy all the statistics or only one node in the clipboard.

It should works with all mods, not only official client. For a sample of how it works you can see the enkeyDEV.5 mod.

First of all you should add 2 buttons in the statistics dialog.

In StatisticsDlg.h add the following lines:

// START enkeyDEV(kei-kun) -copy statistics to clipboard-
CString CopyToClipboard(HTREEITEM childItemm, int level);
CString GetItemText(HTREEITEM treeitem);

afx_msg void OnBnClickedStatBtnCopytoclipboard();
afx_msg void OnBnClickedStatBtnCopyselectedtoclipboard();
// END enkeyDEV(kei-kun) -copy statistics to clipboard-


In StatisticsDlg.cpp) add this two lines:

BEGIN_MESSAGE_MAP(CStatisticsDlg, CResizableDialog)
	//{{AFX_MSG_MAP(CStatisticsDlg)
	ON_WM_SHOWWINDOW()
	ON_WM_SIZE()
//}}AFX_MSG_MAP
// START enkeyDEV(kei-kun) -copy statistics to clipboard-
ON_BN_CLICKED(IDC_STAT_BTN_COPYTOCLIPBOARD, OnBnClickedStatBtnCopytoclipboard)
ON_BN_CLICKED(IDC_STAT_BTN_COPYSELECTEDTOCLIPBOARD, OnBnClickedStatBtnCopyselectedtoclipboard)
// END enkeyDEV(kei-kun) -copy statistics to clipboard-
END_MESSAGE_MAP()


And finally:

// START enkeyDEV(kei-kun/th1) -copy statistics to clipboard-
CString CStatisticsDlg::GetItemText(HTREEITEM treeitem){
	if (treeitem == NULL)
  return "";

	TVITEM item;
	TCHAR szText[1024];	
	item.mask = TVIF_TEXT | TVIF_HANDLE;
	item.hItem = treeitem;
	item.pszText = szText;
	item.cchTextMax = 1024;
	
	if (stattree.GetItem(&item))
  return CString(item.pszText);

	return "";   
}

CString CStatisticsDlg::CopyToClipboard(HTREEITEM childItem, int level)
{
	CString strBuffer;
	int tab_count;
	HTREEITEM hCurrent;
	
	if (childItem == NULL) hCurrent = stattree.GetRootItem();
	else hCurrent = childItem;

	strBuffer.Empty();
	while (hCurrent != NULL)
	{
  for (tab_count = 0; tab_count < level; tab_count++) strBuffer += '\t';
  strBuffer += GetItemText(hCurrent) + "\r\n";
  if (stattree.ItemHasChildren(hCurrent))
  	strBuffer += CopyToClipboard(stattree.GetChildItem(hCurrent), level+1);
  hCurrent = stattree.GetNextItem(hCurrent, TVGN_NEXT);
	}
	return strBuffer;
}

void CStatisticsDlg::OnBnClickedStatBtnCopytoclipboard()
{
	theApp.CopyTextToClipboard("<PRE>\r\n" + CopyToClipboard((HTREEITEM)NULL, 0) + "</PRE>\r\n");
}

void CStatisticsDlg::OnBnClickedStatBtnCopyselectedtoclipboard()
{
    HTREEITEM item = stattree.GetSelectedItem();
    CString strText = GetItemText(item);
    if (stattree.ItemHasChildren(item))
  strText += "\r\n" + CopyToClipboard(stattree.GetChildItem(item), 1);
    theApp.CopyTextToClipboard(strText);
}
// END enkeyDEV(kei-kun/th1) -copy statistics to clipboard-

This post has been edited by kei-kun: 30 March 2003 - 11:23 PM

0

  • Member Options

Page 1 of 1

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users