如何让对话框最大化时,其上的List控件适应对话框的尺寸! 如何让对话框最大化时,其上的List控件适应对话框的尺寸!谢谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 CRECT rect;GetClientRect(&rect);然后MoveWindow(&rect); 重载OnSize()函数,比如List控件和对话框的大小完全一致.void CTestDlg::OnSize(UINT nType, int cx, int cy) { CDialog::OnSize(nType, cx, cy); m_list.MoveWindow(0,0,cx,cy,TRUE);} to:xindao_wang(nike) 用你的方法,运行时出现错误提示,忽略后,可用;但最大化后还原Dialog时,控件尺寸不变, 怎么办? 重载OnSize()函数,比如List控件和对话框的大小完全一致.void CTestDlg::OnSize(UINT nType, int cx, int cy) { CDialog::OnSize(nType, cx, cy); if(cx>0&&cy>0) m_list.MoveWindow(0,0,cx,cy,TRUE);} 处理WM_SIZE消息,因为窗口大小发生变化时回调用这个函数,你可以使用CRect rect;GetClientRect(&rect);m_List.MoveWindow(rect,TRUE);或者m_List.MoveWindow(CRect(0,0,cx,cy),TRUE); 在OnSize()里写这个函数,程序运行报错! if(GetDlgItem(IDC_LIST1)->m_hWnd) { CRect theRect; GetClientRect(&theRect); theRect.left=theRect.left+7; theRect.top=theRect.top+7; theRect.bottom=theRect.bottom-7; theRect.right=theRect.right-7; GetDlgItem(IDC_LIST1)->MoveWindo(&theRect,true); }怎么办???? 在OnSize()里写这个函数CWnd *myWnd;myWnd=GetDlgItem(IDC_LIST1); if(myWnd) { CRect theRect; GetClientRect(&theRect); theRect.left=theRect.left+7; theRect.top=theRect.top+7; theRect.bottom=theRect.bottom-7; theRect.right=theRect.right-7; GetDlgItem(IDC_LIST1)->MoveWindo(&theRect,true); } 在窗口最大化的时候,我怎么改变Button控件的位置? 插入位图问题 vs2010肿么不能用通用版本的strlen? Sleep()的替代函数 System权限变为uers权限(非常急) std:string和bstr*的转换问题? 出错信息的扑捉 如何读取桌面图标的信息? 有关SHBrowseForFolder函数的问题? MSDN不能用 初学者的一个问题 大家提供点思路好吗? Directshow --- VMR sample Pip9编译出错????
void CTestDlg::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
m_list.MoveWindow(0,0,cx,cy,TRUE);
}
用你的方法,运行时出现错误提示,忽略后,可用;但最大化后还原Dialog时,控件尺寸不变, 怎么办?
void CTestDlg::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
if(cx>0&&cy>0)
m_list.MoveWindow(0,0,cx,cy,TRUE);
}
CRect rect;
GetClientRect(&rect);
m_List.MoveWindow(rect,TRUE);
或者
m_List.MoveWindow(CRect(0,0,cx,cy),TRUE);
if(GetDlgItem(IDC_LIST1)->m_hWnd)
{
CRect theRect;
GetClientRect(&theRect);
theRect.left=theRect.left+7;
theRect.top=theRect.top+7;
theRect.bottom=theRect.bottom-7;
theRect.right=theRect.right-7;
GetDlgItem(IDC_LIST1)->MoveWindo(&theRect,true); }
怎么办????
CWnd *myWnd;
myWnd=GetDlgItem(IDC_LIST1);
if(myWnd)
{
CRect theRect;
GetClientRect(&theRect);
theRect.left=theRect.left+7;
theRect.top=theRect.top+7;
theRect.bottom=theRect.bottom-7;
theRect.right=theRect.right-7;
GetDlgItem(IDC_LIST1)->MoveWindo(&theRect,true); }