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

📄 commonlistctrl.cpp

📁 VisualC高级编程技术精粹.rar
💻 CPP
字号:
// CommonListCtrl.cpp : implementation file
//

#include "stdafx.h"
#include "AddressListDll.h"
#include "CommonListCtrl.h"

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

/////////////////////////////////////////////////////////////////////////////
// CCommonListCtrl

CCommonListCtrl::CCommonListCtrl()
{
}

CCommonListCtrl::~CCommonListCtrl()
{
}


BEGIN_MESSAGE_MAP(CCommonListCtrl, CListCtrl)
	//{{AFX_MSG_MAP(CCommonListCtrl)
		// NOTE - the ClassWizard will add and remove mapping macros here.
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CCommonListCtrl message handlers

void CCommonListCtrl::InitListCtrl(CCommonListCtrl *pCmmonListCtrl)
{

	// Add grid for list control
	pCmmonListCtrl->SetExtendedStyle( LVS_EX_GRIDLINES );

	// Set the style of selecting  one row in the list control
	pCmmonListCtrl->SetExtendedStyle( pCmmonListCtrl->GetExtendedStyle() | LVS_EX_FULLROWSELECT );

	// Insert items for the list control
	pCmmonListCtrl->InsertColumn( 0, "姓名", LVCFMT_CENTER, 105 );
	pCmmonListCtrl->InsertColumn( 1, "电话", LVCFMT_CENTER, 150 );
	pCmmonListCtrl->InsertColumn( 2, "地址", LVCFMT_CENTER, 250 );
	
	// Read only for the specified column
	//mmonListCtrl->SetReadOnlyColumns( 0 );	
}

//void CCommonListCtrl::SetReadOnlyColumns(int nColumnIndex, bool bSet)
//{
//	POSITION Pos = m_ReadOnlyColumnsList.Find(nColumnIndex);
//
//	if( (NULL == Pos) && bSet ) 
//	{
//		m_ReadOnlyColumnsList.AddTail( nColumnIndex ); 
//	}
//
//	if( (NULL != Pos) && !bSet ) 
//	{
//		m_ReadOnlyColumnsList.RemoveAt( Pos ); 
//	}
//}

void CCommonListCtrl::SetListCtrlText(CCommonListCtrl *pCmmonListCtrl, PersonInfo_t stPersonInfo)
{
	pCmmonListCtrl->InsertItem( 0, _T("") ); 
	pCmmonListCtrl->SetItemText( 0, 0, stPersonInfo.csName);
	pCmmonListCtrl->SetItemText( 0, 1, stPersonInfo.csTelephone );
	pCmmonListCtrl->SetItemText( 0, 2, stPersonInfo.csAddress );
}

⌨️ 快捷键说明

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