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

📄 gui.cpp

📁 监控软件的客户端: 1.采用select模型; 2.采用多线程进行网络的接收和发送; 3.网络断线自动断开;
💻 CPP
字号:
// GUI.cpp: implementation of the CGUI class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "monitorclientapp.h"
#include "GUI.h"

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

//////////////////////////////////////////////////////////////////////
//destruct

//////////////////////////////////////////////////////////////////////////
BEGIN_MESSAGE_MAP(CListCtrl_Ex, CListCtrl)
	//{{AFX_MSG_MAP(CMyListCtrl)
	ON_WM_LBUTTONDOWN()
	ON_WM_DESTROY()
	ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, OnCustomDraw)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()


void CListCtrl_Ex::OnLButtonDown(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	
	CListCtrl::OnLButtonDown(nFlags, point);
}

void CListCtrl_Ex::OnDestroy()
{
	CListCtrl::OnDestroy();
}


void CListCtrl_Ex::OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult)
{
	NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );

    *pResult = CDRF_DODEFAULT;

	if ( CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage )
	{
        *pResult = CDRF_NOTIFYITEMDRAW;
	}
    else if ( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage )
	{
        *pResult = CDRF_NOTIFYSUBITEMDRAW;
		
		int nItem = static_cast<int>( pLVCD->nmcd.dwItemSpec );
		
		ST_ITEM_DATA oData;
		if( FALSE != m_arrayItemData.Find(nItem, oData) )
		{
			pLVCD->clrText = oData.stRowClr.clrTxt;
			pLVCD->clrTextBk = oData.stRowClr.clrBK;
		}
	}
    else if ( (CDDS_ITEMPREPAINT | CDDS_SUBITEM) == pLVCD->nmcd.dwDrawStage )
	{   
        *pResult = CDRF_DODEFAULT;		
	}
}

//////////////////////////////////////////////////////////////////////////
BOOL CListCtrl_Ex::InitListCtrl( const CString* pString, int nStringCount)
{
	if( nStringCount <= 0 )
		return FALSE;

	// Initial extended style for the list control on this dialog
	DWORD dwStyle = GetExtendedStyle();
	dwStyle |= LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES;
	SetExtendedStyle(dwStyle);
	
	// Insert some columns
	CRect rect;
	GetClientRect(&rect);
	ASSERT( NULL != pString && nStringCount >= 1 );
	float nColInterval = (float)(rect.Width()) / (float)(nStringCount + 1 );
	
	//
	for( int i = 0; i < nStringCount; i++ )
	{
		if( i == nStringCount - 1)
			int nOne = InsertColumn( i, pString[i], LVCFMT_CENTER, nColInterval * 2.0 );
		else
			int nOne = InsertColumn( i, pString[i], LVCFMT_CENTER, nColInterval );
	}
	
	return TRUE;
};



int CListCtrl_Ex::AddRowString( const CString* pStringCell, int nStringCount )
{
	ASSERT( NULL != pStringCell && nStringCount >= 1);
		
	int nCurRow = this->GetItemCount();

	int nItem1 = InsertItem( nCurRow + 1, pStringCell[0] );		

	for( int i = 1; i < nStringCount; i++ )
	{
		SetItemText( nItem1, i, pStringCell[i] );
	}

	return nItem1;
}

BOOL CListCtrl_Ex::DelRow( int nIndexLine  )
{
	this->DeleteItem( nIndexLine );

	return TRUE;
}

BOOL CListCtrl_Ex::EditContent( int nIndexLine, int nIndexRow, const CString& strCmt )
{
	return TRUE;
}

void CListCtrl_Ex::SetRowColor( int nRowIndex, COLORREF clrBK, COLORREF clrTxt )
{
	ST_ITEM_DATA stRowData; 

	stRowData.nKey = nRowIndex; 
	stRowData.stRowClr.clrBK = clrBK; 
	stRowData.stRowClr.clrTxt = clrTxt;

	ST_ITEM_DATA oData;
	if( FALSE == m_arrayItemData.Find(nRowIndex, oData) )
	{
		m_arrayItemData.Add( stRowData );
	}
}

⌨️ 快捷键说明

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