15,976
社区成员
发帖
与我相关
我的任务
分享
// CListCtrlEx message handlers
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);
// 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++;
CString cap;
cap.Format("%d",nItem);
afxDump << cap << "\n";
pButton->Create(cap,dwStyle, rect, this, m_uID);
m_mButton.insert( make_pair( nItem, pButton ) );
int iTopIndex = GetTopIndex();
if ( iTopIndex > 0 )
{
updateListCtrlButtonPos();
}
return;
}

,或者有没有别的方法能达到同样的要求,在线等,急,感谢各位大佬