窗体中放入一个listview控件.我想让这个listview控件随窗体的变大而变大,随窗体的还原而变小。要怎样做。谢谢!!!如VB中:
Private Sub Form_Resize()
ListView1.Width = ScaleWidth
If ListView1.Height > 640 Then ListView1.Height = ScaleHeight - 640
End Sub
Private Sub Form_Resize()
ListView1.Width = ScaleWidth
If ListView1.Height > 640 Then ListView1.Height = ScaleHeight - 640
End Sub
void COracleAssistView::OnSize(UINT nType, int cx, int cy)
{
CFormView::OnSize(nType, cx, cy); CRect rect;
GetClientRect(&rect);
int nWidth = rect.Width();
int nLeight = rect.Height();
if(m_edit.GetSafeHwnd())
{ m_edit.SetWindowPos(this,rect.left + nWidth/100,rect.top +nLeight/100,nWidth-nWidth/100*2,nLeight/100*45,SWP_SHOWWINDOW|SWP_NOZORDER);
} if(m_btnExec.GetSafeHwnd())
{
m_btnExec.SetWindowPos(this,rect.left + nWidth/100*40,
rect.top + nLeight/100*47,nWidth/15,nLeight/100*5 ,SWP_SHOWWINDOW|SWP_NOZORDER);
}
if(m_ctrList.GetSafeHwnd()) //m_ctrlList是listctrl的变量
{ m_ctrList.SetWindowPos(this,rect.left + nWidth/100,
rect.top + nLeight/100*58,nWidth-nWidth/100*2,nLeight/100*52,SWP_SHOWWINDOW|SWP_NOZORDER);
} }