当前位置: 首页>>代码示例>>C++>>正文


C++ TDC::DrawText方法代码示例

本文整理汇总了C++中TDC::DrawText方法的典型用法代码示例。如果您正苦于以下问题:C++ TDC::DrawText方法的具体用法?C++ TDC::DrawText怎么用?C++ TDC::DrawText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TDC的用法示例。


在下文中一共展示了TDC::DrawText方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: if

//
/// Override TWindow virtual member function to paint the control.
//
void
TUrlLink::Paint(TDC& dc, bool /*erase*/, TRect& /*rect*/)
{
  TPointer<TFont>  tmpFnt; // Object wrapping font handle
  TAPointer<tchar> text;   // Pointer to caption dynamic buffer
  // Select the font
  if(!LinkFont){
    HFONT hFont = HFONT(::SendMessage(::GetParent(*this), WM_GETFONT, 0, 0));
    if (!hFont)
      hFont = HFONT(GetStockObject(ANSI_VAR_FONT));
    if (hFont)
      tmpFnt = new TFont(hFont);
  }
  if (LinkFont) {
    CHECK(LinkFont->IsGDIObject());
    dc.SelectObject(*LinkFont);
  }
  else if (tmpFnt) {
    CHECK(((TFont&)tmpFnt).IsGDIObject());
    dc.SelectObject((TFont&)tmpFnt);
  }
  int len = GetWindowTextLength();
  text = new tchar[len+1];
  GetWindowText(text, len+1);
  TRect textRect;
  GetClientRect(textRect);

  TColor textColor = LinkColor;
  if (bOverControl)
    textColor = HoverColor;
  else if (bVisited)
    textColor = VisitedColor;

  TColor oldColor = dc.SetTextColor(textColor);
  int oldMode = dc.SetBkMode(TRANSPARENT);
  dc.DrawText(&text[0], len, textRect, 0);
  dc.SetBkMode(oldMode);
  dc.SetTextColor(oldColor);

  // Restore font
  if (LinkFont || tmpFnt)
    dc.RestoreFont();
}
开发者ID:Meridian59,项目名称:Meridian59,代码行数:46,代码来源:urllink.cpp

示例2: Paint


//.........这里部分代码省略.........
   xfac = (rightx - leftx) / (n-1) ;
	yscale = (double) (rstop - rstart) / (ymax - ymin) ;

	xtickscale = (double) (cstop-cstart) / (double) (xnticks-1) ;
	ytickscale = (double) (rstop-rstart) / (double) (ynticks-1) ;

/*
	Outline the graph, draw ticks, and write their labels
*/

	dc.SelectObject ( *pen ) ;
	dc.MoveTo ( cstart , b-rstart ) ;
	dc.LineTo ( cstop , b-rstart ) ;
	dc.LineTo ( cstop , b-rstop ) ;
	dc.LineTo ( cstart , b-rstop ) ;
	dc.LineTo ( cstart , b-rstart ) ;
	dc.RestorePen () ;

	for (i=0 ; i<ynticks ; i++) {                 /* Y ticks */
		row = rstart + i * ytickscale + 0.5 ;
		if (i  &&  (i < ynticks-1)) {  // Horizontal interior lines
         dc.SelectObject ( *second_pen ) ;
			dc.MoveTo ( cstart , b-row ) ;
			dc.LineTo ( cstop , b-row ) ;
         dc.RestorePen () ;
			}
      if (font_height) {
   		sprintf ( msg , "%*.*lf", yndigits, ynfrac, ymin + i * ydif ) ;
   		rect.bottom = b - (row - ylab_height / 2) ;
   		rect.top = rect.bottom - ylab_height - 1 ;
   		rect.right = cstart - 1 ;
   		rect.left = rect.right - ylab_width - 1 ;
         dc.SelectObject ( *pen ) ;
   		dc.DrawText ( msg , -1 , rect , DT_SINGLELINE | DT_BOTTOM | DT_RIGHT );
         dc.RestorePen () ;
         }
		}

   dc.SelectObject ( *pen ) ;
	prevcol = 0 ;
	for (i=0 ; i<xnticks ; i++) {                         /* X ticks */
		col = cstart + i * xtickscale + 0.5 ;
		dc.MoveTo ( col , b-rstart ) ;
		dc.LineTo ( col , b-(rstart - tick_height) ) ;
		if (i) {  /* Make an additional, unlabeled tick between main ones */
			dc.MoveTo ( (col + prevcol) / 2  , b-rstart ) ;
			dc.LineTo ( (col + prevcol) / 2 , b-(rstart - tick_height/2) ) ;
			}
		prevcol = col ;
		if (font_height) {
			sprintf ( msg , "%*.*lf", xndigits, xnfrac, xmin + i * xdif ) ;
         while (*msg == ' ')          // Remove leading blanks
            strcpy ( msg , msg+1 ) ;
			rect.top = b - (rstart - tick_height) ;
			rect.bottom = rect.top + xlab_height - 1 ;
			rect.right = col + xlab_width / 2 ;
			rect.left = rect.right - xlab_width - 1 ;
			dc.DrawText ( msg , -1 , rect , DT_SINGLELINE | DT_BOTTOM | DT_CENTER);
			}
		}
   dc.RestorePen () ;

   if (font_height) {
	   dc.RestoreFont () ;
   	delete font ;
      }
开发者ID:abishekahluwaila,项目名称:read,代码行数:67,代码来源:DISPLAY.CPP


注:本文中的TDC::DrawText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。