Пример #1
0
void CRuntimeDlg::AutoFit()
{
	// iterate all the child controls accumulating the largest bottom right coord
	CRect rClient(0, 0, 0, 0);
	
	CWnd* pCtrl = GetWindow(GW_CHILD);
	
	while (pCtrl)
	{
		CRect rCtrl;
		pCtrl->GetWindowRect(rCtrl);
		ScreenToClient(rCtrl);
		
		rClient.right = max(rClient.right, rCtrl.right);
		rClient.bottom = max(rClient.bottom, rCtrl.bottom);
		
		pCtrl = pCtrl->GetNextWindow();
	}
	
	// add border
	rClient.right += m_rBorders.right;
	rClient.bottom += m_rBorders.bottom;
	
	// calc new window rect
	CRect rWindow;
	GetWindowRect(rWindow);
	CalcWindowRect(rClient);
	
	rClient = CRect(rWindow.TopLeft(), rClient.Size());

	CPoint ptTopLeft = GetInitialPos();

	if (ptTopLeft.x != -1 || ptTopLeft.y != -1)
		rClient.OffsetRect(ptTopLeft - rClient.TopLeft());

	else // match centerpoints of old and new
		rClient.OffsetRect(rWindow.CenterPoint() - rClient.CenterPoint());
	
	MoveWindow(rClient);
}
Пример #2
0
CTagsBar::CTagsBar(PhotoTagsCollection& tagCollection, ConnectionPointer* link)
 : ConnectionPointer(link), bar_wnd_(tagCollection, L"TagsBar"), wnd_pos_(REGISTRY_SECTION_TAGS_WND, &GetInitialPos())
{
}