Ejemplo n.º 1
0
void CBaseDialog::OnSize(UINT nType, int cx, int cy) 
{
	CDialog::OnSize(nType, cx, cy);

	int iXDelta = cx - m_szInitial.cx;
	int iYDelta = cy - m_szInitial.cy;
	HDWP hDefer = NULL;
	for (MovingChildren::iterator p = m_MovingChildren.begin();  p != m_MovingChildren.end();  ++p)
	{
		if (p->m_hWnd != NULL)
		{
			CRect rcNew(p->m_rcInitial);
			rcNew.OffsetRect(int(iXDelta * p->m_dXMoveFrac), int(iYDelta * p->m_dYMoveFrac));
			rcNew.right += int(iXDelta * p->m_dXSizeFrac);
			rcNew.bottom += int(iYDelta * p->m_dYSizeFrac);
			if (hDefer == NULL)
				hDefer = BeginDeferWindowPos(m_MovingChildren.size());
			UINT uFlags = SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER;
			if ((p->m_dXSizeFrac != 0.0) || (p->m_dYSizeFrac != 0.0))
				uFlags |= SWP_NOCOPYBITS;
			DeferWindowPos(hDefer, p->m_hWnd, NULL, rcNew.left, rcNew.top, rcNew.Width(), rcNew.Height(), uFlags);
		}
	}
	if (hDefer != NULL)
		EndDeferWindowPos(hDefer);

}
void CMsgSignalSelect::OnSize(UINT nType, int cx, int cy)
{
    CDialog::OnSize(nType, cx, cy);

    int iXDelta = cx - m_szInitial.cx;
    int iYDelta = cy - m_szInitial.cy;
    HDWP hDefer = NULL;
    for (MovingChildren::iterator p = m_MovingChildren.begin();  p != m_MovingChildren.end();  ++p)
    {
        if (p->m_hWnd != NULL)
        {
            CRect rcNew(p->m_rcInitial);
            rcNew.OffsetRect(int(iXDelta * p->m_dXMoveFrac), int(iYDelta * p->m_dYMoveFrac));
            rcNew.right += int(iXDelta * p->m_dXSizeFrac);
            rcNew.bottom += int(iYDelta * p->m_dYSizeFrac);
            if (hDefer == NULL)
            {
                hDefer = BeginDeferWindowPos(m_MovingChildren.size());
            }
            UINT uFlags = SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER;
            if ((p->m_dXSizeFrac != 0.0) || (p->m_dYSizeFrac != 0.0))
            {
                uFlags |= SWP_NOCOPYBITS;
            }
            DeferWindowPos(hDefer, p->m_hWnd, NULL, rcNew.left, rcNew.top, rcNew.Width(), rcNew.Height(), uFlags);
        }
    }
    if (hDefer != NULL)
    {
        EndDeferWindowPos(hDefer);
    }

    //if (m_hGripper != NULL)
    //   ::ShowWindow(m_hGripper, (nType == SIZE_MAXIMIZED) ? SW_HIDE : SW_SHOW);
}
Ejemplo n.º 3
0
void CSkinHyperLink::SetLabel(LPCTSTR lpszLabel)
{
	CRect rcNew(0,0,0,0);
	HDC hDC = ::GetDC(m_hWnd);
	HFONT hFont = m_hNormalFont;
	if (NULL == hFont)
		hFont = (HFONT)::SendMessage(m_hWnd, WM_GETFONT, 0, 0L);
	HFONT hOldFont = (HFONT)::SelectObject(hDC, hFont);
	::DrawText(hDC, lpszLabel, -1, &rcNew, DT_CALCRECT);
	::SelectObject(hDC, hOldFont);
	::ReleaseDC(m_hWnd, hDC);
	SetWindowPos(NULL, 0, 0, rcNew.Width(), rcNew.Height(), SWP_NOMOVE);

	SetWindowText(lpszLabel);
}
Ejemplo n.º 4
0
//+---------------------------------------------------------------------------
//
//  Member:     CDispRoot::SetRootSize
//
//  Synopsis:   Set the size of the root container.
//
//  Arguments:  size                new size
//              fInvalidateAll      TRUE if entire area should be invalidated
//
//  Notes:
//
//----------------------------------------------------------------------------
void CDispRoot::SetRootSize(const SIZE& size, BOOL fInvalidateAll)
{
    AssertSz(!_fDrawLock, "Illegal call to SetRootSize inside Draw()");
    
    if(fInvalidateAll)
    {
        _rcContainer.SetSize(size);
        _rcVisBounds.SetSize(size);
        InvalidateRoot(_rcVisBounds, FALSE, FALSE);
        SetFlag(CDispFlags::s_invalAndRecalcChildren);
        RequestRecalc();
        return;
    }

    if(_rcContainer.Size() == size)
	{
		return;
	}

    // invalidate uncovered area
    CRect rcNew(_rcContainer.TopLeft(), size);
    if(rcNew.right != _rcContainer.right)
    {
        InvalidateRoot(
            CRect(min(rcNew.right, _rcContainer.right),
              _rcContainer.top,
              max(rcNew.right, _rcContainer.right),
              max(rcNew.bottom, _rcContainer.bottom)),
            FALSE, FALSE);
    }
    if(rcNew.bottom != _rcContainer.bottom)
    {
        InvalidateRoot(
            CRect(_rcContainer.left,
                  min(rcNew.bottom, _rcContainer.bottom),
                  max(rcNew.right, _rcContainer.right),
                  max(rcNew.bottom, _rcContainer.bottom)),
            FALSE, FALSE);
    }

    // set new container size
    _rcContainer.SetSize(size);
    _rcVisBounds.SetSize(size);
    SetFlag(CDispFlags::s_recalcChildren);
    RequestRecalc();
}
Ejemplo n.º 5
0
        void NFrameBase::ReLayout()
        {
            if(layout_ == LayoutNone || !IsLayoutable())
                return;

            int width = 0;
            int height = 0;

            if(GetParent() != NULL)
            {
                Base::NRect rcParent = GetParent()->GetRect();
                width = rcParent.Width();
                height = rcParent.Height();
            }
            else if(window_ != NULL)
            {
                Base::NRect rcWnd;
                window_->GetRect(rcWnd);
                width = rcWnd.Width();
                height = rcWnd.Height();
            }
            else
            {
                return;
            }

            Base::NSize size = IsAutoSize() ? GetAutoSize() : frameRect_.GetSize();

            Base::NRect rcNew(frameRect_.Left, frameRect_.Top, frameRect_.Left + size.Width, frameRect_.Top + size.Height);

            if(layout_ & LayoutHFill)
            {
                rcNew.Left = margin_.Left;
                rcNew.Right = width - margin_.Right;
            }
            else if(layout_ & LayoutHCenter)
            {
                size.Width = (minSize_.Width <= 0 || size.Width > minSize_.Width) ? size.Width : minSize_.Width;
                size.Width = (maxSize_.Width <= 0 || size.Width < maxSize_.Width) ? size.Width : maxSize_.Width;
                rcNew.Left = (width - margin_.Width() - size.Width) / 2;
                rcNew.Right = rcNew.Left + size.Width;
            }
            else if(layout_ & LayoutLeft)
            {
                rcNew.Left = margin_.Left;
                rcNew.Right = rcNew.Left + size.Width;
            }
            else if(layout_ & LayoutRight)
            {
                rcNew.Right = width - margin_.Right;
                rcNew.Left = rcNew.Right - size.Width;
            }

            if(layout_ & LayoutVFill)
            {
                rcNew.Top = margin_.Top;
                rcNew.Bottom = height - margin_.Bottom;
            }
            else if(layout_ & LayoutVCenter)
            {
                size.Height = (minSize_.Height <= 0 || size.Height > minSize_.Height) ? size.Height : minSize_.Height;
                size.Height = (maxSize_.Height <= 0 || size.Height < maxSize_.Height) ? size.Height : maxSize_.Height;
                rcNew.Top = (height - margin_.Height() - size.Height) / 2;
                rcNew.Bottom = rcNew.Top + size.Height;
            }
            else if(layout_ & LayoutTop)
            {
                rcNew.Top = margin_.Top;
                rcNew.Bottom = rcNew.Top + size.Height;
            }
            else if(layout_ & LayoutBottom)
            {
                rcNew.Bottom = height - margin_.Bottom;
                rcNew.Top = rcNew.Bottom - size.Height;
            }

            SetPosImpl(rcNew.Left, rcNew.Top, true);
            SetSizeImpl(rcNew.Width(), rcNew.Height(), true);
        }