// 从XML设置位置信息属性 HRESULT CControlBase::OnAttributePosChange(const CStringA& strValue, BOOL bLoading) { if (strValue.IsEmpty()) return E_FAIL; m_strPos = strValue; DUIDLG_POSITION dlgpos; dlgpos.nCount=0; LPCSTR pszValue=strValue; while(dlgpos.nCount<4 && pszValue) { pszValue=ParsePosition(pszValue,dlgpos.Item[dlgpos.nCount++]); } if (2 == dlgpos.nCount || 4 == dlgpos.nCount) { if(4 == dlgpos.nCount) { CRect rectParent = CRect(0,0,0,0); CDuiObject* pParent = GetParent(); if(pParent) { rectParent = pParent->GetRect(); } CRect rect; rect.left = PositionItem2Value(dlgpos.Left, rectParent.left, rectParent.right); rect.top = PositionItem2Value(dlgpos.Top, rectParent.top, rectParent.bottom); rect.right = PositionItem2Value(dlgpos.Right, rectParent.left, rectParent.right); rect.bottom = PositionItem2Value(dlgpos.Bottom, rectParent.top, rectParent.bottom); SetRect(rect); } else if(2 == dlgpos.nCount) { //m_uPositionType = (m_uPositionType & ~SizeX_Mask) | SizeX_FitContent; //m_uPositionType = (m_uPositionType & ~SizeY_Mask) | SizeY_FitContent; CRect rectParent = CRect(0,0,0,0); CDuiObject* pParent = GetParent(); if(pParent) { rectParent = pParent->GetRect(); } CRect rect; rect.left = PositionItem2Value(dlgpos.Left, rectParent.left, rectParent.right); rect.top = PositionItem2Value(dlgpos.Top, rectParent.top, rectParent.bottom); if(m_nWidth != 0) { rect.right = rect.left + m_nWidth; }else { rect.right = PositionItem2Value(dlgpos.Left, rectParent.left, rectParent.right); } if(m_nHeight != 0) { rect.bottom = rect.top + m_nHeight; }else { rect.bottom = PositionItem2Value(dlgpos.Top, rectParent.top, rectParent.bottom); } SetRect(rect); } } else dlgpos.nCount = 0; return bLoading?S_FALSE:S_OK; }