对话框伸缩功能(AB伸缩以及ABC伸缩)

1、AB伸缩即把一个对话框分为两部分,可以进行伸缩显示

//获得对话框整体范围
	GetWindowRect(&pFull);
	pHalf = pFull;
	//确定小尺寸对话框范围
	CRect rect;
	m_ctlMorebutton.GetWindowRect(&rect);
	pHalf.bottom = rect.bottom + 20;
	pSize = false;//初始设置为小对话框
	//调用改变尺寸函数
	ChangeDlgSize();

void ChangeDlgSize()
{
	CRect rect;
	CString str;
	if(pSize)
	{
		str = "默认<<";
		rect = pFull;
	}
	else
	{
		str = "更多>>";
		rect = pHalf;
	}
	SetWindowPos(NULL, 0, 0, rect.Width(), rect.Height(), SWP_NOMOVE);//显示对话框
	m_ctlMorebutton.SetWindowText(str);//设置按钮文本
	pSize = !pSize;
}

2、ABC伸缩即一个对话框有3个部分,隐藏中间部分B进行伸缩,也就是连接AC

if ((group_expanded && !show) || (!group_expanded && show))
	{
		group_expanded = !group_expanded;

		int i;
		int height = show ? shrinking_height : -shrinking_height;

		// Hide all controls within the group
		for (i=0; i<arAllGroupCtrls.GetSize(); i++){
			if (hCheckBox != arAllGroupCtrls[i]){
				::ShowWindow(arAllGroupCtrls[i], show ? SW_SHOW : SW_HIDE);
			}
		}

		// Move all controls below
		for (i=0; i<arAllCtrlsBelow.GetSize(); i++){
			CRect rcCtrl;
			::GetWindowRect(arAllCtrlsBelow[i], &rcCtrl);
			pDlg->ScreenToClient(rcCtrl);
			rcCtrl.OffsetRect(0, height);
			::MoveWindow(arAllCtrlsBelow[i], rcCtrl.left, rcCtrl.top, rcCtrl.Width(), rcCtrl.Height(), TRUE);
		}

		// Shirnk/Expand dialog
		CRect rcDialog;
		pDlg->GetWindowRect(rcDialog);
		rcDialog.bottom += height;
		pDlg->SetWindowPos(NULL,0,0, rcDialog.Width(), rcDialog.Height(),SWP_NOMOVE | SWP_NOZORDER);
		pDlg->RedrawWindow();
	}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值