左右分别为两个CFormView的子类CLeftView和CRightView,左边的form中有一个树型空控件,右边为一个Tab控件,现在当CMyWnd最大化后,左右两部分form中的控件怎么样才能随之动态变化大小以正确填充左右的区域?请各位高手大哥帮忙!手头分数不多,只能给80分!
8 个解决方案
#1
在WM_SIZE处理函数中调用每个控件的MoveWindow()函数
#2
up!
最好在最后再加一句UpdataWindow();
最好在最后再加一句UpdataWindow();
#3
那为什么我在CLeftView的OnSize()方法中执行这样的代码报错呢?当执行到“m_Tree.MoveWindow(&rect,TRUE);”是出错,m_Tree是该类中的属性控件的变量:
CRect rect;
this->GetClientRect(&rect);
m_Tree.MoveWindow(&rect,TRUE);
this->UpdateWindow();
CRect rect;
this->GetClientRect(&rect);
m_Tree.MoveWindow(&rect,TRUE);
this->UpdateWindow();
#4
为什么没有人回复呢, zhb1284(zhb1284) 说的方法确实能够实现,但在实现过程中m_Tree.MoveWindow(&rect,TRUE)出错,若不忽略错误就不能执行,为什么
#5
你分析一下这段代码吧,应该没有问题的
void CRecoveryDlg::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
CRect clirect;
CRect rec;
CPoint btnpt;
CPoint refpt;
CPoint ctrlpt;
CSize offset;
GetClientRect(clirect);
refpt = clirect.BottomRight();
CButton* button;
button = (CButton*)GetDlgItem(IDC_CLOSE);
if( button != NULL) {
button->GetWindowRect( rec );
ScreenToClient(rec);
int len = rec.right - rec.left;
rec.right = clirect.right - m_btn.x;
rec.left = clirect.right - m_btn.x - len;
button->MoveWindow(rec, TRUE);
}
button = (CButton*)GetDlgItem(IDC_GET);
if( button != NULL) {
button->GetWindowRect( rec );
ScreenToClient(rec);
int len = rec.right - rec.left;
rec.right = clirect.right - m_btn.x;
rec.left = clirect.right - m_btn.x - len;
button->MoveWindow(rec, TRUE);
}
CListCtrl* listctrl = (CListCtrl *)GetDlgItem(IDC_HISTORYLIST);
if( listctrl != NULL )
{
listctrl->GetWindowRect(rec);
ScreenToClient(rec);
clirect.bottom -= m_list.y ;
clirect.right -= m_list.x ;
clirect.top = rec.top ;
clirect.left = rec.left ;
listctrl->MoveWindow(clirect, TRUE) ;
listctrl->SetColumnWidth(2, LVSCW_AUTOSIZE_USEHEADER);
}
/*
m_button_del.GetWindowRect(rec);
ScreenToClient(rec);
ctrlpt = rec.BottomRight();
offset = refpt - ctrlpt;
rec.OffsetRect(offset);
*/
/*
ScreenToClient(rec);
rec.OffsetRect(offset);
/*
m_get.MoveWindow(rec, TRUE);
/*
m_close.GetWindowRect(rec);
ScreenToClient(rec);
rec.OffsetRect(offset);
m_close.MoveWindow(rec, TRUE);
*/
/*Move Listctrl*/
/* m_listctrl.GetWindowRect(rec);
ScreenToClient(rec);
clirect.top = 2;
clirect.bottom = rec.top - 3;
m_listctrl.MoveWindow(clirect, TRUE);
*/
}
void CRecoveryDlg::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
CRect clirect;
CRect rec;
CPoint btnpt;
CPoint refpt;
CPoint ctrlpt;
CSize offset;
GetClientRect(clirect);
refpt = clirect.BottomRight();
CButton* button;
button = (CButton*)GetDlgItem(IDC_CLOSE);
if( button != NULL) {
button->GetWindowRect( rec );
ScreenToClient(rec);
int len = rec.right - rec.left;
rec.right = clirect.right - m_btn.x;
rec.left = clirect.right - m_btn.x - len;
button->MoveWindow(rec, TRUE);
}
button = (CButton*)GetDlgItem(IDC_GET);
if( button != NULL) {
button->GetWindowRect( rec );
ScreenToClient(rec);
int len = rec.right - rec.left;
rec.right = clirect.right - m_btn.x;
rec.left = clirect.right - m_btn.x - len;
button->MoveWindow(rec, TRUE);
}
CListCtrl* listctrl = (CListCtrl *)GetDlgItem(IDC_HISTORYLIST);
if( listctrl != NULL )
{
listctrl->GetWindowRect(rec);
ScreenToClient(rec);
clirect.bottom -= m_list.y ;
clirect.right -= m_list.x ;
clirect.top = rec.top ;
clirect.left = rec.left ;
listctrl->MoveWindow(clirect, TRUE) ;
listctrl->SetColumnWidth(2, LVSCW_AUTOSIZE_USEHEADER);
}
/*
m_button_del.GetWindowRect(rec);
ScreenToClient(rec);
ctrlpt = rec.BottomRight();
offset = refpt - ctrlpt;
rec.OffsetRect(offset);
*/
/*
ScreenToClient(rec);
rec.OffsetRect(offset);
/*
m_get.MoveWindow(rec, TRUE);
/*
m_close.GetWindowRect(rec);
ScreenToClient(rec);
rec.OffsetRect(offset);
m_close.MoveWindow(rec, TRUE);
*/
/*Move Listctrl*/
/* m_listctrl.GetWindowRect(rec);
ScreenToClient(rec);
clirect.top = 2;
clirect.bottom = rec.top - 3;
m_listctrl.MoveWindow(clirect, TRUE);
*/
}
#6
一般的:
if(&&&.GetSafeHWnd())
{
&&&.SetWindowPos(****,****);
}
if(&&&.GetSafeHWnd())
{
&&&.SetWindowPos(****,****);
}
#7
BinaryPoet(二进制诗人) 诗人的方法是对的!
#8
奇怪,怎么送出去分看不到
#1
在WM_SIZE处理函数中调用每个控件的MoveWindow()函数
#2
up!
最好在最后再加一句UpdataWindow();
最好在最后再加一句UpdataWindow();
#3
那为什么我在CLeftView的OnSize()方法中执行这样的代码报错呢?当执行到“m_Tree.MoveWindow(&rect,TRUE);”是出错,m_Tree是该类中的属性控件的变量:
CRect rect;
this->GetClientRect(&rect);
m_Tree.MoveWindow(&rect,TRUE);
this->UpdateWindow();
CRect rect;
this->GetClientRect(&rect);
m_Tree.MoveWindow(&rect,TRUE);
this->UpdateWindow();
#4
为什么没有人回复呢, zhb1284(zhb1284) 说的方法确实能够实现,但在实现过程中m_Tree.MoveWindow(&rect,TRUE)出错,若不忽略错误就不能执行,为什么
#5
你分析一下这段代码吧,应该没有问题的
void CRecoveryDlg::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
CRect clirect;
CRect rec;
CPoint btnpt;
CPoint refpt;
CPoint ctrlpt;
CSize offset;
GetClientRect(clirect);
refpt = clirect.BottomRight();
CButton* button;
button = (CButton*)GetDlgItem(IDC_CLOSE);
if( button != NULL) {
button->GetWindowRect( rec );
ScreenToClient(rec);
int len = rec.right - rec.left;
rec.right = clirect.right - m_btn.x;
rec.left = clirect.right - m_btn.x - len;
button->MoveWindow(rec, TRUE);
}
button = (CButton*)GetDlgItem(IDC_GET);
if( button != NULL) {
button->GetWindowRect( rec );
ScreenToClient(rec);
int len = rec.right - rec.left;
rec.right = clirect.right - m_btn.x;
rec.left = clirect.right - m_btn.x - len;
button->MoveWindow(rec, TRUE);
}
CListCtrl* listctrl = (CListCtrl *)GetDlgItem(IDC_HISTORYLIST);
if( listctrl != NULL )
{
listctrl->GetWindowRect(rec);
ScreenToClient(rec);
clirect.bottom -= m_list.y ;
clirect.right -= m_list.x ;
clirect.top = rec.top ;
clirect.left = rec.left ;
listctrl->MoveWindow(clirect, TRUE) ;
listctrl->SetColumnWidth(2, LVSCW_AUTOSIZE_USEHEADER);
}
/*
m_button_del.GetWindowRect(rec);
ScreenToClient(rec);
ctrlpt = rec.BottomRight();
offset = refpt - ctrlpt;
rec.OffsetRect(offset);
*/
/*
ScreenToClient(rec);
rec.OffsetRect(offset);
/*
m_get.MoveWindow(rec, TRUE);
/*
m_close.GetWindowRect(rec);
ScreenToClient(rec);
rec.OffsetRect(offset);
m_close.MoveWindow(rec, TRUE);
*/
/*Move Listctrl*/
/* m_listctrl.GetWindowRect(rec);
ScreenToClient(rec);
clirect.top = 2;
clirect.bottom = rec.top - 3;
m_listctrl.MoveWindow(clirect, TRUE);
*/
}
void CRecoveryDlg::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
CRect clirect;
CRect rec;
CPoint btnpt;
CPoint refpt;
CPoint ctrlpt;
CSize offset;
GetClientRect(clirect);
refpt = clirect.BottomRight();
CButton* button;
button = (CButton*)GetDlgItem(IDC_CLOSE);
if( button != NULL) {
button->GetWindowRect( rec );
ScreenToClient(rec);
int len = rec.right - rec.left;
rec.right = clirect.right - m_btn.x;
rec.left = clirect.right - m_btn.x - len;
button->MoveWindow(rec, TRUE);
}
button = (CButton*)GetDlgItem(IDC_GET);
if( button != NULL) {
button->GetWindowRect( rec );
ScreenToClient(rec);
int len = rec.right - rec.left;
rec.right = clirect.right - m_btn.x;
rec.left = clirect.right - m_btn.x - len;
button->MoveWindow(rec, TRUE);
}
CListCtrl* listctrl = (CListCtrl *)GetDlgItem(IDC_HISTORYLIST);
if( listctrl != NULL )
{
listctrl->GetWindowRect(rec);
ScreenToClient(rec);
clirect.bottom -= m_list.y ;
clirect.right -= m_list.x ;
clirect.top = rec.top ;
clirect.left = rec.left ;
listctrl->MoveWindow(clirect, TRUE) ;
listctrl->SetColumnWidth(2, LVSCW_AUTOSIZE_USEHEADER);
}
/*
m_button_del.GetWindowRect(rec);
ScreenToClient(rec);
ctrlpt = rec.BottomRight();
offset = refpt - ctrlpt;
rec.OffsetRect(offset);
*/
/*
ScreenToClient(rec);
rec.OffsetRect(offset);
/*
m_get.MoveWindow(rec, TRUE);
/*
m_close.GetWindowRect(rec);
ScreenToClient(rec);
rec.OffsetRect(offset);
m_close.MoveWindow(rec, TRUE);
*/
/*Move Listctrl*/
/* m_listctrl.GetWindowRect(rec);
ScreenToClient(rec);
clirect.top = 2;
clirect.bottom = rec.top - 3;
m_listctrl.MoveWindow(clirect, TRUE);
*/
}
#6
一般的:
if(&&&.GetSafeHWnd())
{
&&&.SetWindowPos(****,****);
}
if(&&&.GetSafeHWnd())
{
&&&.SetWindowPos(****,****);
}
#7
BinaryPoet(二进制诗人) 诗人的方法是对的!
#8
奇怪,怎么送出去分看不到