本文整理汇总了C++中CPaintDC::TextOut方法的典型用法代码示例。如果您正苦于以下问题:C++ CPaintDC::TextOut方法的具体用法?C++ CPaintDC::TextOut怎么用?C++ CPaintDC::TextOut使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CPaintDC
的用法示例。
在下文中一共展示了CPaintDC::TextOut方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnPaint
void CMainWindow::OnPaint ()
{
CRect rect;
GetClientRect(&rect);
CPaintDC dc (this);
dc.SetViewportOrg(rect.Width()/2, rect.Height()/2);
dc.SetBkMode(TRANSPARENT);
for (int i = 0; i<300; i+=150)
{
LOGFONT lf;
::ZeroMemory(&lf, sizeof(LOGFONT));
lf.lfHeight = 160;
lf.lfHeight = FW_BOLD;
lf.lfEscapement = i;
lf.lfOrientation = i;
::lstrcpy(lf.lfFaceName, _T("Arial"));
CFont font;
font.CreateFontIndirect(&lf);
CFont * pOldFont = dc.SelectObject(&font);
dc.TextOut(0,0, CString(_T("M")));
dc.SelectObject(pOldFont);
}
}
示例2: OnPaint
void CMainWindow::OnPaint ()
{
CPaintDC dc (this);
//
// Initialize the device context.
//
dc.SetMapMode (MM_LOENGLISH);
dc.SetTextAlign (TA_CENTER | TA_BOTTOM);
dc.SetBkMode (TRANSPARENT);
//
// Draw the body of the ruler.
//
CBrush brush (RGB (255, 255, 0));
CBrush* pOldBrush = dc.SelectObject (&brush);
dc.Rectangle (100, -100, 1300, -200);
dc.SelectObject (pOldBrush);
//
// Draw the tick marks and labels.
//
for (int i=125; i<1300; i+=25) {
dc.MoveTo (i, -192);
dc.LineTo (i, -200);
}
for (i=150; i<1300; i+=50) {
dc.MoveTo (i, -184);
dc.LineTo (i, -200);
}
for (i=200; i<1300; i+=100) {
dc.MoveTo (i, -175);
dc.LineTo (i, -200);
CString string;
string.Format (_T ("%d"), (i / 100) - 1);
dc.TextOut (i, -175, string);
}
}