Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SetPos中,注释掉if( pParent != NULL )后面的内容导致在代码中无法设置控件位置 #32

Closed
cuiguanghui opened this issue Oct 10, 2016 · 1 comment

Comments

@cuiguanghui
Copy link

void CControlUI::SetPos(RECT rc, bool bNeedInvalidate)
{
if( rc.right < rc.left ) rc.right = rc.left;
if( rc.bottom < rc.top ) rc.bottom = rc.top;

    CDuiRect invalidateRc = m_rcItem;
    if( ::IsRectEmpty(&invalidateRc) ) invalidateRc = rc;

    if( m_bFloat ) {
        CControlUI* pParent = GetParent();
        /*if( pParent != NULL ) {
            RECT rcParentPos = pParent->GetPos();
            RECT rcCtrl = {rcParentPos.left + rc.left, rcParentPos.top + rc.top, 
                rcParentPos.left + rc.right, rcParentPos.top + rc.bottom};
            m_rcItem = rcCtrl;
            LONG width = rcParentPos.right - rcParentPos.left;
            LONG height = rcParentPos.bottom - rcParentPos.top;
            RECT rcPercent = {(LONG)(width*m_piFloatPercent.left), (LONG)(height*m_piFloatPercent.top),
                (LONG)(width*m_piFloatPercent.right), (LONG)(height*m_piFloatPercent.bottom)};
            m_cXY.cx = rc.left - rcPercent.left;
            m_cXY.cy = rc.top - rcPercent.top;
            m_cxyFixed.cx = rc.right - rcPercent.right - m_cXY.cx;
            m_cxyFixed.cy = rc.bottom - rcPercent.bottom - m_cXY.cy;
        }*/
    }
    else {
        m_rcItem = rc;
    }
    m_rcItem = rc;
    if( m_pManager == NULL ) return;

    if( !m_bSetPos ) {
        m_bSetPos = true;
        if( OnSize ) OnSize(this);
        m_bSetPos = false;
    }

    m_bUpdateNeeded = false;

    if( bNeedInvalidate && IsVisible() ) {
        invalidateRc.Join(m_rcItem);
        CControlUI* pParent = this;
        RECT rcTemp;
        RECT rcParent;
        while( pParent = pParent->GetParent() ) {
            if( !pParent->IsVisible() ) return;
            rcTemp = invalidateRc;
            rcParent = pParent->GetPos();
            if( !::IntersectRect(&invalidateRc, &rcTemp, &rcParent) ) return;
        }
        m_pManager->Invalidate(invalidateRc);
    }
}
@gaodeng
Copy link
Contributor

gaodeng commented Oct 11, 2016

Float 在 CContainerUI::SetFloatPos 里面处理过了。

@qdtroy qdtroy closed this as completed Oct 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants