照着例子做的结果不一样

djh512 2010-01-14 07:02:30
在看孙鑫的视频 有一个讲窗口收缩的
我完全照它一样做的 可是不能实现收缩

void CDlg::OnButton1()
{
CString str;
if(GetDlgItemText(IDC_BUTTON1,str),str=="收缩<<")
{
SetDlgItemText(IDC_BUTTON1,"扩展>>");
}
else
{
SetDlgItemText(IDC_BUTTON1,"收缩<<");
}

static CRect rectLarge;
static CRect rectSmall;

if(rectLarge.IsRectNull())
{
CRect rectSeparator;
GetWindowRect(&rectLarge);
GetDlgItem(IDC_SEPARATOR)->GetWindowRect(&rectSeparator);
rectSmall.left=rectLarge.left;
rectSmall.top=rectLarge.top;
rectSmall.right=rectLarge.right;
rectSmall.bottom=rectLarge.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);
}

}

我跟着调试到SetWindowPos函数 这个参数也是跟视频的例子一样的 为什么不能实现窗口收缩 ?
...全文
49 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
djh512 2010-01-14
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 xwsn007 的回复:]
最后一行改为:
rectSmall.bottom=rectSeparator.bottom;
[/Quote]

寒 我对着看 还研究了 SetWindowPos函数看了半天
是我太不细心了 谢谢了
xwsn007 2010-01-14
  • 打赏
  • 举报
回复
最后一行改为:
rectSmall.bottom=rectSeparator.bottom;
xwsn007 2010-01-14
  • 打赏
  • 举报
回复
rectSmall.left=rectLarge.left;
rectSmall.top=rectLarge.top;
rectSmall.right=rectLarge.right;
rectSmall.bottom=rectLarge.bottom;

这段代码有问题,怎么rectSmall和rectLarge一样啊
djh512 2010-01-14
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 flydreamgg 的回复:]
你的IDC_SEPARATOR没放对地方吧
[/Quote]
放的地方是对的 谢谢
昨夜无风 2010-01-14
  • 打赏
  • 举报
回复
你的IDC_SEPARATOR没放对地方吧

15,979

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧