~$ 存档

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

##

伸缩窗口的代码:

void CVbvbDlg::OnButton1() //伸缩窗口
{
    
    CString str;
    if(GetDlgItemText(IDC_BUTTON1,str),str=="收缩<<")
    {

        SetDlgItemText(IDC_BUTTON1,"扩展>>");
        SetWindowPos(NULL,0,0,rectSmall.Width(),rectSmall.Height(),SWP_NOMOVE | SWP_NOZORDER);
        //SetWindowPos()函数用于改变窗口的配置;
    }
    else
    {
        SetDlgItemText(IDC_BUTTON1,"收缩<<");
        SetWindowPos(NULL,0,0,rectLarge.Width(),rectLarge.Height(),SWP_NOMOVE | SWP_NOZORDER);
    }
}

初始化时获取伸缩窗口的尺寸:

    CRect rectSeparator;
    GetWindowRect((&rectLarge));

    GetDlgItem(IDC_RIGHT)->GetWindowRect((&rectSeparator));
    
    rectSmall.left=rectLarge.left;
    rectSmall.top=rectLarge.top;
    rectSmall.bottom=rectLarge.bottom;
    rectSmall.right=rectSeparator.left;

    SetWindowPos(NULL,0,0,rectSmall.Width(),rectSmall.Height(),SWP_NOMOVE | SWP_NOZORDER);

 

posted on 2017-08-22 21:40  LuoTian  阅读(389)  评论(0编辑  收藏  举报