| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 405 人关注过本帖
标题:MFC中关于对话框扩展的问题,求助~
只看楼主 加入收藏
徐士昊
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2013-10-29
结帖率:0
收藏
已结贴  问题点数:20 回复次数:1 
MFC中关于对话框扩展的问题,求助~
对话框出现时开始是小的
对话框的OnInitDialog()函数中添加如下代码
                    SetDlgItemText(IDC_BUTTON2,"扩展>>");
            CRect SmallRect;
            CRect  LargeRect;
            CRect Separetor;
            GetWindowRect(&LargeRect);//获得对话框原始位置
            GetDlgItem(IDC_SEPARATOR)->    GetWindowRect(&Separetor);//获取图像控件的原始位置
            SmallRect.left=LargeRect.left;
            SmallRect.top=LargeRect.top;
            SmallRect.bottom=Separetor.bottom;
            SmallRect.right=LargeRect.right;
            SetWindowPos(NULL,0,0,SmallRect.Width(),SmallRect.Height(),SWP_NOMOVE|SWP_NOZORDER);
按钮响应函数为
void CExDialogDlg::OnButton2()
{
    // TODO: Add your control notification handler code here
    CString str;
    if(GetDlgItemText(IDC_BUTTON2,str),str=="收缩<<")
    {
        SetDlgItemText(IDC_BUTTON2,"扩展>>");
    }
    else
    {
        SetDlgItemText(IDC_BUTTON2,"收缩<<");
    }
            
    static CRect LargeRect;
    static CRect SmallRect;
        
        if(LargeRect.IsRectNull())
        {
            CRect Separetor;
            GetWindowRect(&LargeRect);//获得对话框原始位置
            GetDlgItem(IDC_SEPARATOR)->    GetWindowRect(&Separetor);//获取图像控件的原始位置
            SmallRect.left=LargeRect.left;
            SmallRect.top=LargeRect.top;
            SmallRect.bottom=Separetor.bottom;
            SmallRect.right=LargeRect.right;
        }
   
    if(GetDlgItemText(IDC_BUTTON2,str),str=="收缩<<")
    {
        SetWindowPos(NULL,0,0,LargeRect.Width(),LargeRect.Height(),SWP_NOMOVE|SWP_NOZORDER);
   
    }
    else
    {
        SetWindowPos(NULL,0,0,SmallRect.Width(),SmallRect.Height(),SWP_NOMOVE|SWP_NOZORDER);
    }

   
}

运行没错误,在点击按钮的时候无法实现功能。
当注释掉OnInitDialog()中的 SetWindowPos(NULL,0,0,SmallRect.Width(),SmallRect.Height(),SWP_NOMOVE|SWP_NOZORDER);时又可以正常使用。
求大神指导
搜索更多相关主题的帖子: 对话框 
2013-10-29 12:26
yuccn
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:何方
等 级:版主
威 望:167
帖 子:6814
专家分:42393
注 册:2010-12-16
收藏
得分:20 
不知道你说什么,

你想干什么?
你的问题是什么?
无法实现什么?

我行我乐
公众号:逻辑客栈
我的博客:
https://blog.yuccn. net
2013-10-29 13:33
快速回复:MFC中关于对话框扩展的问题,求助~
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015344 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved