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


C++ CDC::DrawTextEx方法代码示例

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


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

示例1: RenderContent

void CMultilineList::RenderContent(CDC & dc, CRect & r)
{
   dc.FillRect(r,CBrush::FromHandle(GetSysColorBrush(COLOR_WINDOW)));

   dc.SetBkMode(TRANSPARENT);
   dc.SetTextColor(GetSysColor(COLOR_WINDOWTEXT));

   CPen * origPen = dc.SelectObject(&m_gridPen);

   int y1 = 0;
   int row = 0;

   // determine top visible row and setup y1 to be the top of its rendering area
   for (int yPos = 0; row < m_nRows; row++)
   {
      int thisRowHeight = m_rowHeights[row];

      if ((yPos + thisRowHeight) > m_viewYPos)
      {
         y1 = r.top - (m_viewYPos - yPos);
         break;
      }
      else
      {
         yPos += thisRowHeight;
      }
   }

   int firstRenderedRow = row;

	// for each row
   for (; (row < m_nRows) && (y1 <= r.bottom); row++)
   {
		// start with zero height
      int y2 = y1;

		// for each column
      for (int col = 0, x1 = r.left-m_viewXPos; (col < m_nCols); col++)
      {
			// get the column object (if it exists) or use defaults
         Column column;
         std::map<int,Column>::iterator i = m_columns.find(col);
         if (i != m_columns.end())
         {
            column = i->second;
         }

			// get the cell object (if it exists) or use defaults
         Cell cell;
         map<pair<int,int>,Cell>::iterator j = m_cells.find(make_pair(col,row));
         if (j != m_cells.end())
         {
            cell = j->second;
         }

			// determine the required size of the text, given the column width

         int x2 = x1 + column.m_width;

         CRect textRect(x1,y1,x2,y1);
         textRect.DeflateRect(INNER_PADDING,INNER_PADDING);
         int origRight = textRect.right;
         
         dc.DrawTextEx(cell.m_text,textRect,
            DT_CALCRECT|DT_LEFT|DT_NOPREFIX|DT_TOP|DT_WORDBREAK,
            NULL);
         
         textRect.right = origRight;

			// if this row is selected, fill in the background with the selection color and
			// set the text color
         if (row == m_curSelRow)
         {
            CRect bgRect(textRect);
            bgRect.InflateRect(INNER_PADDING,INNER_PADDING);
            bgRect.bottom = bgRect.top + m_rowHeights[row] + GRID_WIDTH;
            bgRect.top += GRID_WIDTH;
            dc.FillRect(bgRect,CBrush::FromHandle(GetSysColorBrush(COLOR_HIGHLIGHT)));
            dc.SetTextColor(GetSysColor(COLOR_HIGHLIGHTTEXT));
         }
         else
         {
				// else, ensure text color is set to the non-selected color
            dc.SetTextColor(GetSysColor(COLOR_WINDOWTEXT));
         }

         textRect.bottom += INNER_PADDING;
         textRect.bottom += GRID_WIDTH;

			// ensure tallest cell is stored
         if (textRect.bottom > y2)
         {
            y2 = textRect.bottom;
         }

			// render the cell text
         dc.DrawTextEx(cell.m_text,textRect,
            DT_LEFT|DT_NOPREFIX|DT_TOP|DT_WORDBREAK,
            NULL);

//.........这里部分代码省略.........
开发者ID:davecalkins,项目名称:multiline-list-control,代码行数:101,代码来源:MultilineList.cpp


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