MFC实现窗口的伸缩

以上是效果图的显示。

关键的代码,对Button控件的响应:

void CTestDlg::OnButsuo() 

{

	// TODO: Add your control notification handler code here

	CString st;

	if (GetDlgItemText(IDC_BUTSUO,st),st=="收缩<<")

	{

		SetDlgItemText(IDC_BUTSUO,"扩展>>");

	} 

	else

	{

		SetDlgItemText(IDC_BUTSUO,"收缩<<");

	}

	static CRect rectLarge;

	static CRect rectSmall;



	

	if (rectLarge.IsRectNull())

	{

		GetWindowRect(&rectLarge);

		CRect picRect;

		GetDlgItem(IDC_FENGE)->GetWindowRect(&picRect);

		rectSmall.left=rectLarge.left;

		rectSmall.top=rectLarge.top;

		rectSmall.right=rectLarge.right;

		rectSmall.bottom=picRect.bottom;

	} 

	

	if (st=="收缩<<")

	{

		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);

	}

	

}

展开阅读全文

没有更多推荐了,返回首页