1.右键对话框---类向导--消息选择WM_SIZE 添加 处理程序 onsize
2.
void CHttpResp::OnSize(UINT nType, int cx, int cy)
{
CDialogEx::OnSize(nType, cx, cy);
// TODO: 在此处添加消息处理程序代码
if(!IsWindowVisible())
return;
//获取客户区矩形
CRect rect;
GetClientRect(&rect);
//动态改变控件大小
CWnd *m_editcontrol=GetDlgItem(IDC_EDIT1);
m_editcontrol->SetWindowPos(NULL,rect.right/5,rect.bottom/5,rect.right/2,rect.bottom/2,SWP_NOZORDER|SWP_SHOWWINDOW);
//或者
m_editcontrol->Window(rect.right/5,rect.bottom/5,rect.right/2,rect.bottom/2);
(1) MoveWindow():
void MoveWindow(int x,int y,int nWidth,int nHeight);
x, y为控件位置;nWidth、nHeight为控件宽度和高度
(2) SetWindowPos():
BOOL SetWindowPos(const CWnd* pWndI