本文整理汇总了C++中CClientDC::ExtTextOut方法的典型用法代码示例。如果您正苦于以下问题:C++ CClientDC::ExtTextOut方法的具体用法?C++ CClientDC::ExtTextOut怎么用?C++ CClientDC::ExtTextOut使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CClientDC
的用法示例。
在下文中一共展示了CClientDC::ExtTextOut方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CenterText
void CBigIcon::CenterText(CClientDC &dc, LPCSTR lpszStatus, int top)
{
int nMargin;
CRect rect;
TEXTMETRIC tm;
// Leave a horizontal margin equal to the widest character
VERIFY(dc.GetTextMetrics(&tm));
nMargin = tm.tmMaxCharWidth;
// Compute the opaque rect
rect.left = nMargin;
rect.right = m_sizeBitmap.cx - nMargin;
rect.top = top;
rect.bottom = rect.top + tm.tmHeight;
// We need to compute where to draw the text so it is centered
// horizontally
int x = rect.left;
CSize extent = CIntlWin::GetTextExtent(0, dc.m_hDC, lpszStatus, XP_STRLEN(lpszStatus));
if (extent.cx < rect.Width())
x += (rect.Width() - extent.cx) / 2;
// Draw opaquely so we can avoid erasing the old text
dc.ExtTextOut(x, rect.top, ETO_OPAQUE, &rect, lpszStatus, strlen(lpszStatus), NULL);
}
示例2: UpdateDisplay
void CDlgCalcDlg::UpdateDisplay(LPCTSTR pszDisplay)
{
CClientDC dc (this);
CFont* pOldFont = dc.SelectObject (GetFont ());
CSize size = dc.GetTextExtent (pszDisplay);
CRect rect = m_rect;
rect.InflateRect (-2, -2);
int x = rect.right - size.cx - m_cxChar;
int y = rect.top + ((rect.Height () - m_cyChar) / 2);
dc.ExtTextOut (x, y, ETO_OPAQUE, rect, pszDisplay, NULL);
dc.SelectObject (pOldFont);
}