15,978
社区成员
发帖
与我相关
我的任务
分享
void CListDlgDlg::OnSize(UINT nType, int cx, int cy)
{
CDialogEx::OnSize(nType, cx, cy);
// TODO: 在此处添加消息处理程序代码
if(m_List.GetSafeHwnd()==NULL) return;
CRect rect;
this->GetClientRect(&rect);
CPoint pot = rect.TopLeft();
m_List.SetWindowPos(NULL, pot.x+10, pot.y+10,
rect.Width()-pot.x-20, rect.Height()-pot.y-20, NULL);
TRACE("RECT: %d, %d\n", rect.Width(), rect.Height());
CRect rectList;
m_List.GetWindowRect(&rectList);
TRACE("List: %d, %d\n", rectList.Width(), rectList.Height());
}
如果要让列也自动缩放,那么就要复杂很多,请参考:
把ListCtrl最后一列自动调整大小;并在对话框大小改变时随对话框改变