本文整理汇总了C++中CControlBase::GetRect方法的典型用法代码示例。如果您正苦于以下问题:C++ CControlBase::GetRect方法的具体用法?C++ CControlBase::GetRect怎么用?C++ CControlBase::GetRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CControlBase
的用法示例。
在下文中一共展示了CControlBase::GetRect方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnControlUpdate
LRESULT CDlgPopup::OnControlUpdate(CRect rcUpdate, BOOL bUpdate, CControlBase *pUpdateControlBase)
{
if(pUpdateControlBase == NULL) return 0;
if(bUpdate)
{
pUpdateControlBase->SetUpdate(FALSE);
}
CRect rcAllUpDate = rcUpdate;
if(m_bInit)
{
BOOL bFind = false;
for (size_t i = 0; i < m_vecControl.size(); i++)
{
CControlBase * pControlBase = m_vecControl.at(i);
if (pControlBase)
{
if(bFind)
{
if (pControlBase->GetVisible() && !(pControlBase->GetRect() & rcUpdate).IsRectEmpty())
{
rcAllUpDate |= pControlBase->GetRect();
pControlBase->SetUpdate(FALSE);
}
}
else if(pControlBase == pUpdateControlBase)
{
bFind = true;
}
}
}
}
if(GetSafeHwnd())
{
InvalidateRect(&rcAllUpDate);
}
return 0L;
};
示例2: InitUI
// 初始化窗口控件
void CDuiPanel::InitUI(CRect rcClient, DuiXmlNode pNode)
{
CRect rcTemp;
int nStartX = 0;
int nStartY = 0;
CControlBase * pControlBase = NULL;
// 加载所有窗口控件
if(pNode)
{
m_nVirtualHeight = 0;
m_nVirtualWidth = 0;
for (DuiXmlNode pControlElem = pNode.first_child(); pControlElem; pControlElem=pControlElem.next_sibling())
{
if(pControlElem != NULL)
{
CString strControlName = pControlElem.name();
CControlBase* pControl = _CreateControlByName(strControlName);
if(pControl)
{
pControl->Load(pControlElem);
if(pControl->IsClass(CArea::GetClassName()))
{
// Area不能响应鼠标,必须加到Area列表中
m_vecArea.push_back(pControl);
}else
{
m_vecControl.push_back(pControl);
}
CRect rcCtrl = pControl->GetRect();
if(rcCtrl.bottom > m_nVirtualHeight)
{
m_nVirtualHeight = rcCtrl.bottom - m_rc.top;
}
if(rcCtrl.right > m_nVirtualWidth)
{
m_nVirtualWidth = rcCtrl.right - m_rc.left;
}
}
}
}
// 需要的总高度大于显示区高度才会显示垂直滚动条
m_pControScrollV->SetVisible(m_nVirtualHeight > m_rc.Height());
((CDuiScrollVertical*)m_pControScrollV)->SetScrollMaxRange(m_nVirtualHeight);
// 需要的总宽度大于显示区宽度才会显示垂直滚动条
m_pControScrollH->SetVisible(m_nVirtualWidth > m_rc.Width());
((CDuiScrollHorizontal*)m_pControScrollH)->SetScrollMaxRange(m_nVirtualWidth);
}
m_bInit = true;
}
示例3: SetControlRect
// 设置控件的位置
void CDuiPanel::SetControlRect(CRect rc)
{
m_rc = rc;
if(m_pDuiPluginObject)
{
m_pDuiPluginObject->SetRect(rc);
}
CRect rcTemp;
for (size_t i = 0; i < m_vecControl.size(); i++)
{
CControlBase * pControlBase = m_vecControl.at(i);
if (pControlBase)
{
UINT uControlID = pControlBase->GetControlID();
if(SCROLL_V == uControlID)
{
rcTemp = m_rc;
rcTemp.left = rcTemp.right - m_nScrollWidth;
}else
if(SCROLL_H == uControlID)
{
rcTemp = m_rc;
rcTemp.top = rcTemp.bottom - m_nScrollWidth;
}else
{
rcTemp = pControlBase->GetRect();
if(rcTemp.bottom > m_nVirtualHeight)
{
// 刷新Panel的虚拟高度
m_nVirtualHeight = rcTemp.bottom - m_rc.top;
}
if(rcTemp.right > m_nVirtualWidth)
{
// 刷新Panel的虚拟宽度
m_nVirtualWidth = rcTemp.right - m_rc.left;
}
continue;
}
pControlBase->SetRect(rcTemp);
}
}
// 需要的总高度大于显示区高度才会显示滚动条
m_pControScrollV->SetVisible(m_nVirtualHeight > m_rc.Height());
((CDuiScrollVertical*)m_pControScrollV)->SetScrollMaxRange(m_nVirtualHeight);
// 需要的总宽度大于显示区宽度才会显示垂直滚动条
m_pControScrollH->SetVisible(m_nVirtualWidth > m_rc.Width());
((CDuiScrollHorizontal*)m_pControScrollH)->SetScrollMaxRange(m_nVirtualWidth);
}
示例4: DrawControl
//.........这里部分代码省略.........
}
// 根据bUseTitleFont决定用标题字体还是普通字体
BSTR bsItemTitle = strItemTitle.AllocSysString();
graphics.DrawString(bsItemTitle, (INT)wcslen(bsItemTitle),
itemInfo.bUseTitleFont ? &fontTitle : &font, rect, &strFormatColumn, itemInfo.bUseTitleFont ? &solidBrushT : &solidBrushItem);
::SysFreeString(bsItemTitle);
// 画单元格内容
if(!bSingleLine)
{
rect.Offset(0, (Gdiplus::REAL)m_nRowHeight / 2 + 2);
rect.Height = (Gdiplus::REAL)m_nRowHeight / 2 - 4;
BSTR bsItemContent = itemInfo.strContent.AllocSysString();
graphics.DrawString(bsItemContent, (INT)wcslen(bsItemContent), &font, rect, &strFormatColumn, &solidBrushItem);
::SysFreeString(bsItemContent);
}
// 设置单元格子控件的位置
for(size_t k = 0; k < itemInfo.vecControl.size(); k++)
{
CControlBase* pControl = itemInfo.vecControl.at(k);
if(pControl)
{
CRect rcParent = CRect(nPosItemX, m_nHeaderHeight + nVI*m_nRowHeight + 1,
(int)(rect.X+rect.Width), (nVI+1)*m_nRowHeight - 1);
if((int)(rect.GetRight()) > nContentWidth)
{
// 最后一列需要减去滚动条宽度
rcParent.right -= m_nScrollWidth;
}
rcParent.OffsetRect(m_rc.left - m_nVirtualLeft, m_rc.top - (nYViewPos + m_nHeaderHeight));
pControl->SetPositionWithParent(rcParent);
CRect rcControl = pControl->GetRect();
// 只有当前在显示范围内的控件设置为可见
if( (rcControl.top < m_rc.top) || (rcControl.bottom > m_rc.bottom) ||
(rcControl.left < m_rc.left) || (rcControl.right > m_rc.right) )
{
pControl->SetVisible(FALSE);
}else
{
pControl->SetVisible(TRUE);
}
}
}
if(j == 0)
{
// 为了使第二列开始是对齐的,所以第二列开始位置按照第一列的宽度计算
nPosItemX = itemInfo.rcItem.right;
}else
{
nPosItemX += itemInfo.rcItem.Width();
}
}
// 画分隔线(采用拉伸模式)
if(m_pImageSeperator != NULL)
{
// 使用拉伸模式画图
graphics.DrawImage(m_pImageSeperator, RectF(0, (Gdiplus::REAL)(m_nHeaderHeight + (nVI+1)*m_nRowHeight), (Gdiplus::REAL)(nContentWidth-2), (Gdiplus::REAL)m_sizeSeperator.cy),
0, 0, (Gdiplus::REAL)m_sizeSeperator.cx, (Gdiplus::REAL)m_sizeSeperator.cy, UnitPixel);
}else
if(m_clrSeperator.GetValue() != Color(0, 0, 0, 0).GetValue())
{
// 未指定图片,并且分隔线显色不是全0,则画矩形
示例5: OnControlUpdate
// 控件界面刷新
LRESULT CDuiPanel::OnControlUpdate(CRect rcUpdate, BOOL bUpdate, CControlBase *pUpdateControlBase)
{
if(pUpdateControlBase == NULL) return 0;
if(bUpdate)
{
pUpdateControlBase->SetUpdate(FALSE);
}
int nVirtualTop = 0;
if(m_nVirtualHeight > m_rc.Height())
{
// 计算显示位置
CDuiScrollVertical* pScrollV = (CDuiScrollVertical*)m_pControScrollV;
int nCurPos = pScrollV->GetScrollCurrentPos(); // 当前top位置
int nMaxRange = pScrollV->GetScrollMaxRange();
nVirtualTop = (nMaxRange > 0) ? nCurPos*(m_nVirtualHeight-m_rc.Height())/nMaxRange : 0; // 当前显示的是虚拟图片中什么位置开始的图片
}
int nVirtualLeft = 0;
if(m_nVirtualWidth > m_rc.Width())
{
// 计算显示位置
CDuiScrollHorizontal* pScrollH = (CDuiScrollHorizontal*)m_pControScrollH;
int nCurPosH = pScrollH->GetScrollCurrentPos(); // 当前top位置
int nMaxRangeH = pScrollH->GetScrollMaxRange();
nVirtualLeft = (nMaxRangeH > 0) ? nCurPosH*(m_nVirtualLeft-m_rc.Width())/nMaxRangeH : 0; // 当前显示的是虚拟图片中什么位置开始的图片
}
CRect rcAllUpDate = rcUpdate;
if(m_bInit)
{
BOOL bFind = false;
for (size_t i = 0; i < m_vecControl.size(); i++)
{
CControlBase * pControlBase = m_vecControl.at(i);
if (pControlBase)
{
if(bFind)
{
if (pControlBase->GetVisible() && !(pControlBase->GetRect() & rcUpdate).IsRectEmpty())
{
rcAllUpDate |= pControlBase->GetRect();
pControlBase->SetUpdate(FALSE);
}
}
else if(pControlBase == pUpdateControlBase)
{
bFind = true;
}
}
}
}
// 按照滚动位置修改更新区域
rcAllUpDate.OffsetRect(-nVirtualLeft, -nVirtualTop);
rcAllUpDate |= m_rc;
InvalidateRect(&rcAllUpDate);
return 0L;
};