⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 onlinelist.cpp

📁 好用的网络文件传输工具
💻 CPP
字号:
// OnlineList.cpp : implementation file
//
//*************************************************************
//作者:赵明
//EMAIL:zmpapaya@hotmail.com;papaya_zm@sina.com
//主页:http://h2osky.126.com
/********************************************************/
#include "stdafx.h"
#include "client1.h"
#include "OnlineList.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// COnlineList

COnlineList::COnlineList()
{
}

COnlineList::~COnlineList()
{
}


BEGIN_MESSAGE_MAP(COnlineList, CListCtrl)
	//{{AFX_MSG_MAP(COnlineList)
	ON_WM_CREATE()
	ON_NOTIFY_REFLECT(NM_DBLCLK, OnDblclk)
	ON_NOTIFY_REFLECT(NM_RCLICK, OnRclick)
	ON_NOTIFY_REFLECT(NM_CLICK, OnClick)
//	ON_NOTIFY_REFLECT(NM_CLICK, OnClick)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// COnlineList message handlers

int COnlineList::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CListCtrl::OnCreate(lpCreateStruct) == -1)
		return -1;

    //加载脸部图案

	//SetBkColor(RGB(0,128,128));

	return 0;
}

void COnlineList::AddItem(filesendinfo * seinfo)
{
	LVITEM			lvi;

	lvi.mask = LVIF_TEXT | LVIF_IMAGE;
	lvi.iItem = GetItemCount();
  //  lvi.iImage = i;
	lvi.iSubItem = 0;
//	lvi.s=0;
	lvi.pszText = "";
	lvi.cchTextMax = 64;
	InsertItem(&lvi);
	SetItemText(lvi.iItem,0,seinfo->name);
CString aaa;
aaa.Format("%d k",seinfo->length/1000);
SetItemText(lvi.iItem,1,aaa.GetBuffer(0));

//SetItemText(lvi.iItem,2,seinfo->date);
aaa.ReleaseBuffer();
//	SetItemText(lvi.iItem,2,name);
//	SetItemText(lvi.iItem,3,(char *)m_csPath);
//	SetItemText(lvi.iItem,4,(char *)m_csAttrib);
SetHotItem(lvi.iItem);			//标注当前项目
	EnsureVisible(lvi.iItem,true);	//滚动影响的卷轴
	Update(lvi.iItem);
//strcpy(name1[lvi.iItem],name2);
//strcpy(name1[lvi.iItem+1],"none");
//strcpy(nameph[lvi.iItem],namepath);
//AfxMessageBox(name1[lvi.iItem]);
}
void COnlineList::AddItemtwo(int fileno,int now,int byes,int type,int speed,int threadno)
{
LVITEM			lvi;

	lvi.mask = LVIF_TEXT ;
	lvi.iItem = GetItemCount();
	itemtoitem[lvi.iItem]=threadno;
	filedono[fileno]=lvi.iItem;
  // lvi.iImage = threadno;
	lvi.iSubItem = 0;
//	lvi.s=0;
	lvi.pszText = "";
	lvi.cchTextMax = 64;
	InsertItem(&lvi);
	SetItemText(lvi.iItem,0,zmfile[fileno].name);
CString aaa;
while(now>0)
{
aaa=aaa+'|';
now-=2;
}

SetItemText(lvi.iItem,1,aaa.GetBuffer(0));
aaa.Format("%d k",byes/1000);
SetItemText(lvi.iItem,3,aaa.GetBuffer(0));
aaa.Format("%d k/s",speed);
SetItemText(lvi.iItem,2,aaa.GetBuffer(0));
switch(type)
{
case 0:
	aaa="下载中";
	break;
case 1:
	aaa="下载中";
	break;
case 2:
	aaa="已完成";
break;
}
SetItemText(lvi.iItem,4,aaa.GetBuffer(0));
//SetItemText(lvi.iItem,2,seinfo->date);
aaa.ReleaseBuffer();
//	SetItemText(lvi.iItem,2,name);
//	SetItemText(lvi.iItem,3,(char *)m_csPath);
//	SetItemText(lvi.iItem,4,(char *)m_csAttrib);
SetHotItem(lvi.iItem);			//标注当前项目
	EnsureVisible(lvi.iItem,true);	//滚动影响的卷轴
	Update(lvi.iItem);
//strcpy(name1[lvi.iItem],name2);
//strcpy(name1[lvi.iItem+1],"none");
//strcpy(nameph[lvi.iItem],namepath);
//AfxMessageBox(name1[lvi.iItem]);
}

void COnlineList::Remove(char *name)
{
	CString str;
	for(int i = 0; i < GetItemCount(); i++){
		str = GetItemText(i,0);
		if(strcmp(str, name) == 0){
			DeleteItem(i);
			break;
		}
	}
}


void COnlineList::OnDblclk(NMHDR* pNMHDR, LRESULT* pResult) 
{
	NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
	CWnd* pParentWnd = GetParent();
int aa;
if	(pParentWnd != NULL){ 
			
	aa	=pParentWnd->GetDlgCtrlID();
		}

//CString aaa;
//aaa.Format("%d",aa);
//AfxMessageBox(aaa);
if(aa==IDD_DIALOG1){
	CString str;

	int iSel = pNMListView->iItem;
//	str.Format("the no is %d",iSel);

//	AfxMessageBox(str);
	if(iSel>=0){
/*	if (iSel >= 0 ){
		str = GetItemText(iSel,0);
		CWnd* pParentWnd = GetParent();
		while (pParentWnd != NULL){ 
			if (pParentWnd->IsFrameWnd()){
				break;
			}
			pParentWnd = pParentWnd->GetParent();
		}
		if (pParentWnd != NULL)
	       pParentWnd->SendMessage(WM_CLOSE, 0, (LPARAM)&str);
	}
*///Sleep(300);

	::AfxGetMainWnd()->SendMessage(CLT_ONSE,0, (LPARAM)&iSel);
	}
}
//::PostMessage(::AfxGetApp()->m_pMainWnd->m_hWnd,CLT_ONSE,(WPARAM)this,0);
	*pResult = 0;
}

void COnlineList::OnRclick(NMHDR* pNMHDR, LRESULT* pResult) 
{
	// TODO: Add your control notification handler code here
		NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
	CWnd* pParentWnd = GetParent();
int aa;
if	(pParentWnd != NULL){ 
			
	aa	=pParentWnd->GetDlgCtrlID();
		}

 

	int iSel = pNMListView->iItem;
 
	if(iSel>=0){
 
	::AfxGetMainWnd()->SendMessage(AA,0, (LPARAM)&itemtoitem[iSel]);
//	}
}
	*pResult = 0;
}

void COnlineList::OnClick(NMHDR* pNMHDR, LRESULT* pResult) 
{
	// TODO: Add your control notification handler code here
		// TODO: Add your control notification handler code here
		NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
	CWnd* pParentWnd = GetParent();
int aa;
if	(pParentWnd != NULL){ 
			
	aa	=pParentWnd->GetDlgCtrlID();
		}

//CString aaa;
//aaa.Format("%d",aa);
//AfxMessageBox(aaa);
if(aa==IDD_DIALOG3){
//	CString str;

	int iSel = pNMListView->iItem;
//	str.Format("the no is %d",iSel);

//	AfxMessageBox(str);
	if(iSel>=0){
 
	::AfxGetMainWnd()->SendMessage(BB,0, (LPARAM)&itemtoitem[iSel]);
	}
}
	*pResult = 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -