对话框界面裁剪,SetWindowPos函数,部分显示

cheney83 2008-07-18 09:44:47
我想让一个对话框只显示其右上1/4的东西,就是只显示2,怎么做?
-------------
| | |
| 1 | 2 |
| | |
-------------
| | |
| 3 | 4 |
| | |
-------------
我在其他地方看到了只显示1可以用SetWindowPos实现,这个函数能实现显示2吗?
void CVideoNetDlg::OnButtonClip()
{
// TODO: Add your control notification handler code here
CString str;
if(GetDlgItemText(IDC_BUTTON_CLIP,str),str == "<<")
{
SetDlgItemText(IDC_BUTTON_CLIP,">>"); //IDC_BUTTON_CLIP按钮的ID
}
else
{
SetDlgItemText(IDC_BUTTON_CLIP,"<<");
}

static CRect rectLarge,rectSmall;
if(rectLarge.IsRectNull())
{
CRect rectSeparator1;
GetWindowRect(&rectLarge);
//IDC_SEPARATOR就是1和2中间那条线的ID
GetDlgItem(IDC_SEPARATOR)->GetWindowRect(&rectSeparator1);
rectSmall.left = rectLarge.left;
rectSmall.top = rectLarge.top;
rectSmall.right = rectLarge.right;
rectSmall.bottom = rectSeparator1.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);
}

}
...全文
156 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
cheney83 2008-07-18
  • 打赏
  • 举报
回复
多谢!搞定了~~
qt_freelancer 2008-07-18
  • 打赏
  • 举报
回复
试试这个

CRect rcOld;
CRect rcNew;
GetClientRect(&rcOld);
rcNew.left = rcOld.right - rcOld.Width()/2;
rcNew.right =rcOld.right;
rcNew.top = rcOld.top;
rcNew.bottom = rcOld.bottom - rcOld.Height()/2;
HRGN hrgn = CreateRectRgnIndirect(rcNew);
SetWindowRgn(hrgn,true);
Chivalry 2008-07-18
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 jimoguilai 的回复:]
lz试试看把
rectSmall.left = rectLarge.left;
rectSmall.top = rectLarge.top;
设置为2的左上角的值
[/Quote]

当然了,
rectSmall.right = rectLarge.right;
rectSmall.bottom = rectSeparator1.bottom;
是2的下角
Chivalry 2008-07-18
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 jimoguilai 的回复:]
lz试试看把
rectSmall.left = rectLarge.left;
rectSmall.top = rectLarge.top;
设置为2的左上角的值
[/Quote]

当然了,
rectSmall.right = rectLarge.right;
rectSmall.bottom = rectSeparator1.bottom;
是2的左下角
Chivalry 2008-07-18
  • 打赏
  • 举报
回复
lz试试看把
rectSmall.left = rectLarge.left;
rectSmall.top = rectLarge.top;
设置为2的左上角的值
Chivalry 2008-07-18
  • 打赏
  • 举报
回复
---------
¦ ¦ ¦
¦ 1¦ 2 ¦
¦ ¦ ¦
----------
¦ ¦ ¦
¦ 3¦ 4 ¦
¦ ¦ ¦
---------
Chivalry 2008-07-18
  • 打赏
  • 举报
回复
-------------
¦ ¦ ¦
¦ 1¦ 2¦
¦ ¦ ¦
-------------
¦ ¦ ¦
¦ 3¦ 4¦
¦ ¦ ¦
-------------
Chivalry 2008-07-18
  • 打赏
  • 举报
回复
-------------
¦ ¦ ¦
¦ 1¦ 2 ¦
¦ ¦ ¦
-------------
¦ ¦ ¦
¦ 3¦ 4 ¦
¦ ¦ ¦
-------------
Chivalry 2008-07-18
  • 打赏
  • 举报
回复
-------------
¦ ¦ ¦
¦ 1 ¦ 2 ¦
¦ ¦ ¦
-------------
¦ ¦ ¦
¦ 3 ¦ 4 ¦
¦ ¦ ¦
-------------

先替lz排个版,呵呵

15,979

社区成员

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

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