//
// 收缩按钮实现对话框伸缩功能
void CTestDlg::OnButton2()
{
// TODO: Add your control notification handler code here
CString str;
if(GetDlgItemText(IDC_BUTTON2,str),str=="收缩<<")
{
SetDlgItemText(IDC_BUTTON2,"伸展>>");
}
else if(str=="伸展>>")
{
SetDlgItemText(IDC_BUTTON2,"收缩<<");
}
static CRect rectLarge,rectSmall;
CRect rectSeparator;
if(rectLarge.IsRectEmpty())
{
GetWindowRect(&rectLarge);
GetWindowRect(&rectSmall);
GetDlgItem(IDC_SEPERATOR)->GetWindowRect(&rectSeparator);
rectSmall.bottom = rectSeparator.bottom;
}
if(str=="收缩<<")
{
// 用了SWP_NOZORDER,就忽略第一个参数,故用NULL
// 用SWP_NOMOVE,就忽略了x和y,故用0,0
SetWindowPos(NULL,0,0,rectSmall.Width(),rectSmall.Height(),SWP_NOMOVE|SWP_NOZORDER);
}
else
{
SetWindowPos(NULL,0,0,rectLarge.Width(),rectLarge.Height(),SWP_NOMOVE|SWP_NOZORDER);
}
}
//CTestDlg::OnOK() 覆盖基类的OnOk(),但是它末尾还是调用了基类的CDialog::OnOK(),因为要注释掉它
void CTestDlg::OnOK()
{
// TODO: Add extra validation here
// CDialog::OnOK(); //注释掉基类的OnOk(),这按回车键就不会关闭对话框了.
}
//---
//---