Ejemplo n.º 1
0
//更新用户
bool CUserListView::UpdateUserItem(IUserItem * pIUserItem)
{
	//效验状态
	ASSERT(pIUserItem!=NULL);
	if (GetSafeHwnd()==NULL) return false;
	
	//查找用户
	LVFINDINFO FindInfo;
	memset(&FindInfo,0,sizeof(FindInfo));
	FindInfo.flags=LVFI_PARAM;
	FindInfo.lParam=(LPARAM)pIUserItem;
	int iItem=FindItem(&FindInfo);
	if (iItem==-1) return false;

	//更新用户
	if (m_wColumnCount>0)
	{
		int nImageStation=GetImageStation(pIUserItem);
		SetItem(iItem,0,LVIF_IMAGE|LVIF_TEXT,GetDisplayText(pIUserItem,0),nImageStation,0,0,0);
	}
	for (WORD i=1;i<m_wColumnCount;i++) 
	{
		SetItemText(iItem,i,GetDisplayText(pIUserItem,i));
	}

	//更新列表
	UpdataUserList();

	return true;
}
Ejemplo n.º 2
0
//加入用户
bool CUserListView::InsertUserItem(tagUserData * pUserData)
{
	//效验状态
	ASSERT(pUserData!=NULL);
	if (GetSafeHwnd()==NULL) return false;

	//查找用户
	LVFINDINFO FindInfo;
	memset(&FindInfo,0,sizeof(FindInfo));
	FindInfo.flags=LVFI_PARAM;
	FindInfo.lParam=(LPARAM)pUserData;
	int iItem=FindItem(&FindInfo);

	//用户名
	if (iItem==-1)
	{
		int nImageStation=GetImageStation(pUserData);
		int nInsertStation=GetInsertStation(pUserData);
		iItem=InsertItem(nInsertStation,pUserData->szName,nImageStation);
		SetItemData(iItem,(DWORD_PTR)pUserData);
	}

	//填写资料
	FillUserListItem(iItem,pUserData);
	return true;
}
Ejemplo n.º 3
0
//填写资料
void CUserListView::FillUserListItem(int iItem, tagUserData * pUserData)
{
	//更新用户
	if (m_wColumnCount>0)
	{
		int nImageStation=GetImageStation(pUserData);
		SetItem(iItem,0,LVIF_IMAGE|LVIF_TEXT,GetDisplayText(pUserData,0),nImageStation,0,0,0);
	}
	for (WORD i=1;i<m_wColumnCount;i++) SetItemText(iItem,i,GetDisplayText(pUserData,i));

	return;
}
Ejemplo n.º 4
0
//填写资料
void CUserListView::FillUserListItem(int iItem, tagUserData * pUserData)
{
	//更新用户
	if (m_wColumnCount==0)return;

	//用户头像
	int nImageStation=GetImageStation(pUserData);
	SetItem(iItem,0,LVIF_IMAGE|LVIF_TEXT,GetDisplayText(pUserData,0),nImageStation,0,0,0);

	for (WORD i=1;i<m_wColumnCount-1;i++) 
	{
		SetItemText(iItem,i,GetDisplayText(pUserData,i));
	}

	//获取行数
	int nItemCount = GetItemCount();

	//旁观信息
	if(nItemCount>1)
	{
		for ( int j=0; j<nItemCount;j++)
		{
			//获取玩家
			tagUserData *pLookUserData = (tagUserData *)GetItemData(j);
			if(pLookUserData->cbUserStatus!=US_LOOKON)continue;

			for ( int i=0; i<nItemCount;i++)
			{
				if(i==j)continue;
				tagUserData *pTargetUserData = (tagUserData *)GetItemData(i);
				if ( pTargetUserData == NULL ) continue;
				if ( pTargetUserData->dwUserID == pLookUserData->dwUserID ) continue;
				if ( pTargetUserData->wChairID != pLookUserData->wChairID ) continue;
				SetItemText(j,m_wColumnCount-1,pTargetUserData->szName);
				break;
			}
			if(i==nItemCount)SetItemText(j,m_wColumnCount-1,TEXT("该用户已离开"));
		}
	}
	return;
}
Ejemplo n.º 5
0
//绘画函数
void CUserListView::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
	CRect rcItem=lpDrawItemStruct->rcItem;
	CDC * pDC=CDC::FromHandle(lpDrawItemStruct->hDC);

	int iItem=lpDrawItemStruct->itemID;
	int iCount=GetHeaderCtrl()->GetItemCount();
	int iBeen=rcItem.left;
	TCHAR szBuffer[1024];
	IUserItem *pIUserItem = (IUserItem *)GetItemData(iItem);

	GetItemRect(iItem, rcItem, LVIR_LABEL);

	for (int i=0;i<iCount;i++)
	{
		CRect rcSubItem;
		int iWidth=GetColumnWidth(i);

		GetSubItemRect(iItem,i,LVIR_LABEL,rcSubItem);
		if ( i == 0 )
		{
			GetSubItemRect(iItem,i,LVIR_ICON,rcSubItem);

			if (lpDrawItemStruct->itemState&ODS_FOCUS) pDC->FillSolidRect(&rcSubItem,RGB(10,36,106)); 
			else pDC->FillSolidRect(&rcSubItem,GetBkColor());

			if (lpDrawItemStruct->itemState&ODS_FOCUS) pDC->SetTextColor(RGB(255,255,255));
			else if ( 0 < pIUserItem->GetUserData()->cbMemberOrder && DTP_USER_ACCOUNTS== m_wDataDescribe[i]) pDC->SetTextColor(RGB(255,0,0));
			else pDC->SetTextColor(RGB(0,0,0));

			//绘画标志
			UINT uImageIndex=GetImageStation(pIUserItem);
			m_StatusImage.Draw(pDC,uImageIndex,CPoint(rcSubItem.left,rcSubItem.top),ILD_TRANSPARENT);

			GetItemText(iItem,i,szBuffer,sizeof(szBuffer));

			GetSubItemRect(iItem,i,LVIR_LABEL,rcSubItem);

			if (lpDrawItemStruct->itemState&ODS_FOCUS) pDC->FillSolidRect(&rcSubItem,RGB(10,36,106)); 
			else pDC->FillSolidRect(&rcSubItem,GetBkColor());

			rcSubItem.top+=3;
			pDC->DrawText(szBuffer,lstrlen(szBuffer),&rcSubItem,DT_LEFT|DT_END_ELLIPSIS);
		}
		else
		{		
			
			if (lpDrawItemStruct->itemState&ODS_FOCUS) pDC->FillSolidRect(&rcSubItem,RGB(10,36,106)); 
			else pDC->FillSolidRect(&rcSubItem,GetBkColor());

			if (lpDrawItemStruct->itemState&ODS_FOCUS) pDC->SetTextColor(RGB(255,255,255));
			else if ( 0 < pIUserItem->GetUserData()->cbMemberOrder && DTP_GAME_ID == m_wDataDescribe[i]) pDC->SetTextColor(RGB(255,0,0));
			else pDC->SetTextColor(RGB(0,0,0));

			GetItemText(iItem,i,szBuffer,sizeof(szBuffer));

			CRect rcTempItem =rcSubItem;
			rcTempItem.left +=2; 
			rcTempItem.right +=2; 
			rcTempItem.top+=3;
			pDC->DrawText(szBuffer,lstrlen(szBuffer),&rcTempItem,DT_LEFT|DT_END_ELLIPSIS);
		}
	}

	//绘画选择
	if (lpDrawItemStruct->itemState&ODS_FOCUS) pDC->DrawFocusRect(&rcItem);

	return;
}
Ejemplo n.º 6
0
//获取位图
int CUserListView::GetImageStation(IUserItem * pIUserItem)
{
	//变量定义
	tagUserData * pUserData=pIUserItem->GetUserData();
	return GetImageStation(pUserData);
}
Ejemplo n.º 7
0
//绘画函数
void CUserListView::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
	CRect rcItem=lpDrawItemStruct->rcItem;
	CDC * pDC=CDC::FromHandle(lpDrawItemStruct->hDC);
	int nSavedDC = pDC->SaveDC();
	int iItem=lpDrawItemStruct->itemID;
	int iCount=GetHeaderCtrl()->GetItemCount();
	int iBeen=rcItem.left;
	LV_ITEM lvi;
	lvi.mask = LVIF_IMAGE | LVIF_STATE;
	lvi.iItem = iItem;
	lvi.iSubItem = 0;
	lvi.stateMask = 0xFFFF;     // get all state flags
	GetItem(&lvi);

	BOOL bSelect =((lvi.state & LVIS_DROPHILITED)
		|| ( (lvi.state & LVIS_SELECTED)
		&& ((GetFocus() == this)
		|| (GetStyle() & LVS_SHOWSELALWAYS)
		)
		)
		);
	tagUserData * pUserItem=(tagUserData *)GetItemData(iItem);

	CRect rcBounds, rcLabel, rcIcon;
	GetItemRect(iItem, rcBounds, LVIR_BOUNDS);
	CRect rcHighlight;
	CRect rcWnd;
	GetClientRect(&rcWnd);
	rcHighlight = rcBounds;
	rcHighlight.left = rcLabel.left;
	rcHighlight.right = rcWnd.right +1 ;

	if (bSelect)
	{
		pDC->FillSolidRect(&rcHighlight,RGB(49,105,198)); 
		pDC->SetTextColor(RGB(255,255,255));
	}
	else
	{
		pDC->FillSolidRect(&rcHighlight,RGB(165,189,213)); 
		pDC->SetTextColor(RGB(49,85,132));
	}
	TCHAR szBuffer[1024];
	for (int i=0;i<iCount;i++)
	{

		int iWidth=GetColumnWidth(i);
		GetSubItemRect(iItem,i,LVIR_LABEL,rcItem);
		if (i==1)
		{
			if (m_StatusImage)
			{
				m_StatusImage.Draw(pDC, GetImageStation(pUserItem), 
					CPoint(rcItem.left, rcItem.top),
					ILD_TRANSPARENT |ILC_MASK );
			}
		}
		if (i==2)
		{
			m_pIUserFaceRes->DrawSmallFace(pDC,rcItem.left,rcItem.top,pUserItem->szFace,pUserItem->cbGender);

		}
		GetItemText(iItem,i,szBuffer,sizeof(szBuffer));

		pDC->DrawText(szBuffer,lstrlen(szBuffer),&rcItem,DT_LEFT|DT_END_ELLIPSIS);

	}

	pDC->RestoreDC( nSavedDC );

	return;


	/*	if (lpDrawItemStruct->itemState==0)
	{
	CDC BitmapDC;
	BitmapDC.CreateCompatibleDC(pDC);
	BitmapDC.SelectObject(&m_Bitmap);
	pDC->BitBlt(rcItem.left,rcItem.top,rcItem.Width(),rcItem.Height(),&BitmapDC,0,0,SRCCOPY);

	}
	else pDC->FillSolidRect(&rcItem,RGB(255,255,255)); 
	*/

}