本文整理汇总了C++中CGridListCtrlEx::GetDC方法的典型用法代码示例。如果您正苦于以下问题:C++ CGridListCtrlEx::GetDC方法的具体用法?C++ CGridListCtrlEx::GetDC怎么用?C++ CGridListCtrlEx::GetDC使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGridListCtrlEx
的用法示例。
在下文中一共展示了CGridListCtrlEx::GetDC方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetTextRect
//------------------------------------------------------------------------
//! Returns dimensions of the cell text clicked
//!
//! @param owner The list control being clicked
//! @param nRow The index of the row
//! @param nCol The index of the column
//! @param cellText The contents of the cell clicked
//! @return The dimensions of the cell text
//------------------------------------------------------------------------
CRect CGridColumnTraitHyperLink::GetTextRect(CGridListCtrlEx& owner, int nRow, int nCol, const CString& cellText)
{
CRect rect;
ASSERT(nRow != -1);
CDC* pDC = owner.GetDC();
CFont* pOldFont = pDC->SelectObject(owner.GetCellFont());
CSize size = pDC->GetTextExtent(cellText);
pDC->SelectObject(pOldFont);
owner.ReleaseDC(pDC);
owner.GetCellRect(nRow, nCol, LVIR_LABEL, rect);
HDITEM hditem = { 0 };
hditem.mask = HDI_FORMAT;
owner.GetHeaderCtrl()->GetItem(nCol, &hditem);
// First item (Label) doesn't have a margin (Subitems does)
if (nCol != 0 && !(hditem.fmt & HDF_CENTER))
{
if (hditem.fmt & HDF_RIGHT)
rect.OffsetRect(-7, 0);
else
rect.OffsetRect(4, 0);
}
if (hditem.fmt & HDF_CENTER)
rect.DeflateRect((rect.Width() - size.cx) / 2, 0);
else if (hditem.fmt & HDF_RIGHT)
rect.left = rect.right - size.cx;
else
rect.right = rect.left + size.cx;
return rect;
}