VC6实现伸缩对话框

虽不太难 还是写来以后会方便不少 

 

IDC_S是一个 图像 控件 用于指明分割窗口的位置

void  CZzDlg::OnOK() 
{
    CString str;
    GetDlgItemText(IDOK,str);
    
if(str=="")
    
{
        SetDlgItemText(IDOK,
"");
    }
else
    
{
        SetDlgItemText(IDOK,
"");

    }

    
static CRect rectLarge;
    
static CRect rectSmall;
    
if(rectLarge.IsRectNull())
    
{
        GetWindowRect(
&rectLarge);

        CRect rectSeparator;

        GetDlgItem(IDC_S)
->GetWindowRect(&rectSeparator);

        rectSmall.left
=rectLarge.left;
        rectSmall.top
=rectLarge.top;
        rectSmall.right
=rectLarge.right;
        rectSmall.bottom
=rectSeparator.bottom;

    }

        
if(str=="")
        
{
            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);
        }

}

 

 

参考文献:VC++编程详解 作者:孙鑫

你可能感兴趣的:(C++/VC++)