在VC编译器中,我想实现对话框的收缩与扩展,一开始,利用picture控件在OnInitDialog()中把窗口设置成收缩的状态,然后想调用Button控件实现对话框的扩展、收缩,但使用的SetWindowPos()函数好像不起作用,请各位帮帮忙呀。谢谢啦主代码如下:
void CTest1Dlg::OnButton1() //利用button实现对话框的扩展、收缩
{
// TODO: Add your control notification handler code here static CRect rectLarge;
static CRect rectSmall;
CRect rectSeparator;
GetDlgItem(IDC_SEPARATOR)->GetWindowRect(&rectSeparator);
GetWindowRect(&rectLarge);

rectSmall.left =rectLarge.left ;
rectSmall.top =rectLarge.top;
rectSmall.right =rectLarge.right; 
rectSmall.bottom =rectSeparator.bottom ;   if(m_isCreate==FALSE)  
{
GetDlgItem(IDC_BTNOPEN)->SetWindowText("关闭");
::SetWindowPos(this->m_hWnd ,NULL,0,0,rectLarge.Width (),rectLarge.Height (),SWP_NOMOVE|SWP_NOZORDER);
      
m_isCreate=TRUE;
}
else
{
GetDlgItem(IDC_BTNOPEN)->SetWindowText("启用");
::SetWindowPos(this->m_hWnd ,NULL,0,0,rectSmall.Width (),rectSmall.Height (),SWP_NOMOVE|SWP_NOZORDER);
        
m_isCreate=FALSE;
}}

解决方案 »

  1.   

    你的rectSmall跟rectLarge是一样大的(都是IDC_SEPARATOR的大小)
    怎么实现收缩、放大啊
      

  2.   

    我猜你这里要写的是这样的
    rectSmall.left =rectSeparator.left ;
    rectSmall.top =rectSeparator.top;
    rectSmall.right =rectSeparator.right;  
    rectSmall.bottom =rectSeparator.bottom ;
      

  3.   

    rectLarge没有获得值吧,然后就赋值给rectSmall,用一个值怎么改变大小
      

  4.   

    回复2楼的:
    rectSmall.left =rectSeparator.left ;
    rectSmall.top =rectSeparator.top;
    rectSmall.right =rectSeparator.right;   
    rectSmall.bottom =rectSeparator.bottom ;
    这样的代码,好像不行呀。
    不过还是谢谢啦