我
我试了加上HDN_ENDTRACK的处理函数,在该处理函数中,会对Button list 中的每个button->MoveWindow(), button都是在最后一列,当我创建多行时,会出现垂直滚动条,这时当调整button那一列大小时,并且滚动条拉到最底部时,button会出现错位,跑到上面去,例如:ClistCtrl显示从第三行开始(垂直滚动条拉直最底部时),那么第一行和第二行的button就会跑到上面去,如下代码,各位大侠有没什么好的办法?代码该如何修改?对隐藏的button该如何处理?
CMyListCtrl::OnHdnEndTrack()
{
int nRowNum = GetItemCount();
for(int iRow = 0; iRow < nRowNum; iRow++)
{
CRect obCellRect;
GetSubItemRect(iRow, phdr->iItem, LVIR_BOUNDS, obCellRect);
CalculateCellRect(phdr->iItem,iRow,obCellRect);
int left = obCellRect.right - 15;
int top = obCellRect.top; CRect btnRect(left,top,obCellRect.right,obCellRect.bottom); if((iRow < BtnMap.size())
{
BtnMap[iRow]->MoveWindow(&btnRect);
BtnMap[iRow]->Invalidate();
}
}
this->Invalidate();
}
我试了加上HDN_ENDTRACK的处理函数,在该处理函数中,会对Button list 中的每个button->MoveWindow(), button都是在最后一列,当我创建多行时,会出现垂直滚动条,这时当调整button那一列大小时,并且滚动条拉到最底部时,button会出现错位,跑到上面去,例如:ClistCtrl显示从第三行开始(垂直滚动条拉直最底部时),那么第一行和第二行的button就会跑到上面去,如下代码,各位大侠有没什么好的办法?代码该如何修改?对隐藏的button该如何处理?
CMyListCtrl::OnHdnEndTrack()
{
int nRowNum = GetItemCount();
for(int iRow = 0; iRow < nRowNum; iRow++)
{
CRect obCellRect;
GetSubItemRect(iRow, phdr->iItem, LVIR_BOUNDS, obCellRect);
CalculateCellRect(phdr->iItem,iRow,obCellRect);
int left = obCellRect.right - 15;
int top = obCellRect.top; CRect btnRect(left,top,obCellRect.right,obCellRect.bottom); if((iRow < BtnMap.size())
{
BtnMap[iRow]->MoveWindow(&btnRect);
BtnMap[iRow]->Invalidate();
}
}
this->Invalidate();
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货