www.pudn.com > list-button.rar > ListCtrlEx.cpp, change:2014-11-27,size:1627b


// ListCtrlEx.cpp : 实现文件 
// 
 
#include "stdafx.h" 
#include "list-button.h" 
#include "ListCtrlEx.h" 
 
 
// CListCtrlEx 
 
IMPLEMENT_DYNAMIC(CListCtrlEx, CListCtrl) 
 
CListCtrlEx::CListCtrlEx() 
{ 
	m_uID = 0; 
} 
 
CListCtrlEx::~CListCtrlEx() 
{ 
} 
 
 
BEGIN_MESSAGE_MAP(CListCtrlEx, CListCtrl) 
END_MESSAGE_MAP() 
 
 
 
// CListCtrlEx 消息处理程序 
void CListCtrlEx::createItemButton( int nItem, int nSubItem, HWND hMain ) 
{ 
	CRect rect; 
	int offset = 0; 
 
	// Make sure that the item is visible 
	//if( !EnsureVisible(nItem, TRUE))  
	//	return ; 
 
	GetSubItemRect(nItem, nSubItem, LVIR_BOUNDS, rect); 
//	rect.bottom = rect.top + 150; 
 
	// Now scroll if we need to expose the column 
	CRect rcClient; 
	GetClientRect(rcClient); 
	if( offset + rect.left < 0 || offset + rect.left > rcClient.right ) 
	{ 
		CSize size; 
		size.cx = offset + rect.left; 
		size.cy = 0; 
		Scroll(size); 
		rect.left -= size.cx; 
	} 
 
	rect.left += offset;	 
	rect.right = rect.left + GetColumnWidth(nSubItem); 
	if(rect.right > rcClient.right)  
		rect.right = rcClient.right; 
	//basic code end 
 
		rect.bottom = rect.top + rect.Height(); 
 
	int iPageCout = GetCountPerPage(); 
	if ( nItem >= iPageCout ) 
	{ 
		rect.top += rect.Height(); 
		rect.bottom += rect.Height(); 
	} 
 
	DWORD dwStyle =  WS_CHILD | WS_VISIBLE; 
	CButtonEx *pButton = new CButtonEx(nItem,nSubItem,rect,hMain); 
	m_uID++; 
	pButton->Create(_T("查看"),dwStyle, rect, this, m_uID); 
	m_mButton.insert( make_pair( nItem, pButton ) ); 
 
	/*int iTopIndex = GetTopIndex(); 
	if ( iTopIndex > 0 ) 
	{ 
	updateListCtrlButtonPos(); 
	} 
	*/ 
	return; 
}