//========================================================================
  //TITLE:
  //    MiniUtilityFramework(九):CText和TEXT
  //AUTHOR:
  //    norains
  //DATE:
  //    Wednesday 26-March-2009
  //Environment:
  //    VISUAL STUDIO 2005 + WINDOWS CE 5.0
  //========================================================================
  
  CText和微软的Static Control类似,都是用以显示文字信息。最大的不同,可能就在于CText能更方便设置字体的信息,比如:大小,颜色等等。
  
  CText的public接口比较多,不过大多数都只是用来设置文字显示的形式:

class CText  {public: //-------------------------------------------------------------------- //Description: // Set all the property for the control // //--------------------------------------------------------------------- BOOL SetProperty(const Text::Property &Property); //-------------------------------------------------------------------- //Description: // Get all the property of the control // //--------------------------------------------------------------------- Text::Property GetProperty(); //-------------------------------------------------------------------- //Description: // Set the strikeOut // //--------------------------------------------------------------------- void SetStrikeOut(BOOL bStrikeOut); //-------------------------------------------------------------------- //Description: // Set the underline // //--------------------------------------------------------------------- void SetUnderline(BOOL bUnderline); //-------------------------------------------------------------------- //Description: // Set the italic // //--------------------------------------------------------------------- void SetItalic(BOOL bItalic); //-------------------------------------------------------------------- //Description: // Specifies the weight of the font in the range 0 through 1000. For example,  //400 is normal and 700 is bold. If this value is zero, a default weight is used.  // //--------------------------------------------------------------------- BOOL SetWeight(int iWeight); //-------------------------------------------------------------------- //Description: // Get the position as rect // //--------------------------------------------------------------------- RECT GetPosition(); //-------------------------------------------------------------------- //Description: // Set the point size of text // //--------------------------------------------------------------------- void SetPointSize(int iPointSize); //-------------------------------------------------------------------- //Description: // Set Format. // //Parameters: // The value you should see the uFormat of DrawText() //-------------------------------------------------------------------- void SetFormat(UINT uFormat); //-------------------------------------------------------------------- //Description: // Set the background color // //-------------------------------------------------------------------- void SetBkColor(COLORREF crColor);  //-------------------------------------------------------------------- //Description: // Set the text color // //-------------------------------------------------------------------- void SetTextColor(COLORREF crColor); //-------------------------------------------------------------------- //Description: // Set the background mode. // //Parameters: // iMode: [in] The value is just like as follow: //  OPAQUE      -- Background is filled with the current background color before the text,  //      hatched brush, or pen is drawn.  //  TRANSPARENT -- Background remains untouched.  //-------------------------------------------------------------------- BOOL SetBkMode(int iMode); //-------------------------------------------------------------------- //Description: // Display the text stored. // //-------------------------------------------------------------------- void Draw(HDC hdc);  //-------------------------------------------------------------------- //Description: // Set the text. If you want to display the text ,you should call the Display() // //-------------------------------------------------------------------- BOOL SetText(const TSTRING &strText); //-------------------------------------------------------------------- //Description: // Set the control position // //-------------------------------------------------------------------- void SetPosition(const RECT &rcWndPos); //-------------------------------------------------------------------- //Description: // Get the text. // //-------------------------------------------------------------------- TSTRING GetText(); //-------------------------------------------------------------------- //Description: // Set font face name // //-------------------------------------------------------------------- BOOL SetFaceName(const TSTRING &strFaceName);public: CText(); virtual ~CText();private: Text::Property m_Property;

配置文件可选的字段也不少,但并不复杂:

TYPE:类型,取值必须为TEXT,标明当前控件为TEXT
  
  RECT_POS:该控件在窗口的位置。
  
  POINT_SIZE:字体的大小。
  
  WEIGHT:粗细,取值为0~900。
  
  FORMAT:格式。取值和DrawText的uFormat参数的一致,有如下类型(取自DrawText的说明文档):
    
    DT_BOTTOM         Justifies the text to the bottom of the rectangle. You must combine this value with DT_SINGLELINE.
    
    DT_CALCRECT       Determines the width and height of the rectangle. If the rectangle includes multiple lines of text, DrawText uses the width of the rectangle pointed to by the lpRect parameter and extends the base of the rectangle to bound the last line of text. If the rectangle includes only one line of text, DrawText modifies the right side of the rectangle so that it bounds the last character in the line. In either case, DrawText returns the height of the formatted text but does not draw the text. Before calling DrawText, an application must set the right and bottom members of the RECT structure pointed to by lpRect. These members are updated with the call to DrawText.  
    
    DT_CENTER         Centers text horizontally in the rectangle.
    
    DT_END_ELLIPSIS   Truncates a text string that is wider than the display rectangle and adds an ellipsis to indicate the truncation.
    
    DT_EXPANDTABS     Expands tab characters. The default number of characters per tab is eight. 
    
    DT_INTERNAL       Uses the system font to calculate text metrics. 
    
    DT_LEFT           Aligns text to the left.
    
    DT_NOCLIP         Draws without clipping. DrawText is somewhat faster when DT_NOCLIP is used.
    
    DT_NOPREFIX       Turns off processing of prefix characters. Normally, DrawText interprets the mnemonic-prefix character & as a directive to underscore the character that follows, and the mnemonic-prefix characters && as a directive to print a single &. By specifying DT_NOPREFIX, this processing is turned off.
    
    DT_RIGHT          Aligns text to the right.
    
    DT_RTLREADING     Layout in right-to-left reading order for bi-directional text when the font selected into the hdc is a Hebrew or Arabic font. The default reading order for all text is left-to-right.
    
    DT_SINGLELINE     Displays text on a single line only. Carriage returns and linefeeds do not break the line.
    
    DT_TABSTOP        Sets tab stops. Bits 8–15, which form the high-order byte of the low-order word, of the uFormat parameter specify the number of characters for each tab. The default number of characters per tab is eight. You cannot use the DT_CALCRECT, DT_EXTERNALLEADING, DT_INTERNAL, DT_NOCLIP, and DT_NOPREFIX values with the DT_TABSTOP value.
    
    DT_TOP            Top-justifies text. You must combine this value with DT_SINGLELINE.
    
    DT_VCENTER        Centers text vertically. You must combine this value with DT_SINGLELINE.
    
    DT_WORD_ELLIPSIS  Truncates any word that does not fit in the display rectangle and adds an ellipsis.
    
    DT_WORDBREAK      Breaks words. DrawText automatically breaks lines between words if a word would extend past the edge of the rectangle specified by the lpRect parameter. A carriage return-linefeed sequence also breaks the line.
  
  COLOR:文本的颜色
  
  TRANSPARENT_MODE:决定背景是否透明。取值为TRUE或FALSE。当为FALSE时,背景颜色为TRANSPARENT_COLOR所确定的数值。
  
  STRING:连接的字符串
  
  FONT_FACE_NAME:字体。注意,该字段指的不是字体的文件名,而是字体名。也就是说,该字段取值不会是FONT的KEY值。该数值可以通过CCommon::GetFontNameFromFile读取相应的字体文件来获得。
  
  ITALIC:斜体
  
  UNDERLINE:下划线
  
  STRIKEOUT:删除线
  
  
  配置文件的字段,和Text::Property中的变量基本上是对应:
  
  namespace Text
  {
   struct Property
   {
    RECT rcWndPos; 
    TSTRING strText;
    UINT uFormat;
    int iPointSize;
    int iBkMode;
    COLORREF crTextColor;
    COLORREF crBkColor;
    int iWeight;
    BOOL bItalic;
    BOOL bUnderline;
    BOOL bStrikeOut;
    TSTRING strFaceName;
   };
  }
  
  如果CText的使用仅仅是用来显示相应的信息,并不打算在代码中对显示信息进行变更,可以在配置文件中设置STRING字段的指向,不仅能够方便地显示文字,还能在调用SetCurLanguage后自动变更显示的内容。如果需要在代码中进行操控,我们只需要通过GetText函数获取相应的对象,然后再调用SetText函数即可:
  
  CText *pText = GetText(TEXT("TXT_EXIT"));
  pText->SetText(TEXT("退出"));
  
  这是一个随着语言的不同,显示不同语言的“导航”的例子:
  [TXT_TITLE_NAVI]
  TYPE=TEXT
  RECT_POS=11,8,162,39
  POINT_SIZE=26
  WEIGHT=700
  FORMAT=DT_LEFT|DT_SINGLELINE|DT_VCENTER
  COLOR=0,255,0
  TRANSPARENT_MODE=TRUE
  FONT_FACE_NAME=kaiti_GB2312
  STRING=STR_NAVI
  
  [STR_NAVI]
  TYPE=STRING
  EN="NAVI"
  CHS="导航"
  CHT="導航"

再分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://blog.csdn.net/jiangjunshow

MiniUtilityFramework 九 CText和TEXT相关推荐

  1. JavaFX UI控件教程(九)之Text Field

    翻译自   Text Field 本章讨论文本字段控件的功能. 的TextField类实现接受并显示文本输入的UI控制.它提供了从用户接收文本输入的功能.与另一个文本输入控件一起,PasswordFi ...

  2. IP-Address TextBox

    http://www.codeproject.com/Articles/4693/IP-Address-TextBox 可以下载试用效果.个人感觉功能很强大,但输入时让人不太舒服.可以参考. ntro ...

  3. Paper:《NÜWA: Visual Synthesis Pre-training for Neural visUal World creAtion,女娲:用于神经视觉世界创造的视觉》翻译与解读

    Paper:<NÜWA: Visual Synthesis Pre-training for Neural visUal World creAtion,女娲:用于神经视觉世界创造的视觉>翻 ...

  4. CSS中的text-shadow。

    text-shadow(文字投影),box-shadow(容器投影),border-radius(圆角)这三个属性估计以后用的比较多,记录 一下.目前不支持IE系列(不过可以使用其他方法实现,下文有详 ...

  5. CSS3-文本-text-shadow

    一.text-shadow 语法: text-shadow : none | <length> none | [<shadow>, ] * <shadow> 或no ...

  6. 搭建asp会议签到系统 第三章 会议签到

    搭建asp会议签到系统 第一章 账密登录 第二章 生成会议签到二维码 第三章 会议签到 第四章 会议统计 第三章 会议签到 搭建asp会议签到系统 前言 一.制作checkin前端页面 二.读取并展示 ...

  7. NLP实践——以T5模型为例训练seq2seq模型

    NLP实践--以T5模型为例训练seq2seq模型 0. 介绍 1. 数据下载与加载 2. 创建模型 3. 训练评估函数 4. 模型训练 5. 模型预测 0. 介绍 回顾这两年NLP领域的研究,生成式 ...

  8. VB.NET绘图8---总结

    <VB.NET 绘图基础>吧,因为篇幅实在有点长,计划分成:Graphics章.Pen章.Brush章.Text章.由于涉及到的内容比较多,加之包含比较多的实例代码,所以根据内容的长短把每 ...

  9. 模板引擎Thymeleaf?来这一篇就够用了

    写在前面 模板页面中的 html 上需要声明 Thymeleaf 的命名空间,具体代码如下 <html xmlns:th="http://www.thymeleaf.org" ...

  10. asp毕业设计——基于asp+sqlserver的酒店预定管理系统设计与实现(毕业论文+程序源码)——酒店预定管理系统

    基于asp+sqlserver的酒店预定管理系统设计与实现(毕业论文+程序源码) 大家好,今天给大家介绍基于asp+sqlserver的酒店预定管理系统设计与实现,文章末尾附有本毕业设计的论文和源码下 ...

最新文章

  1. 记录一次java项目上线部署
  2. PIE SDK热力图
  3. 声明式编程与函数式编程_实用程序类与函数式编程无关
  4. C++11 标准新特性: 右值引用与转移语义
  5. 腾讯云数据库Redis助力百万企业远程办公
  6. html5 动态 menuitem,利用HTML 5中的Menu和Menuitem元素快速创建菜单
  7. Web 前端怎样入门?
  8. scala中的基础语法
  9. Java 学生成绩管理系统
  10. 不是计算机网络教室功能的是,精选:谈计算机网络教室在教学中的应用原稿
  11. 室内设计手绘表现手法基础教程
  12. 融易投3周年庆——欢乐送豪礼
  13. 人有见识就不轻易发怒;宽恕人的过失便是自己的荣耀。
  14. HDU 5473(There was a kingdom-凸包+dp)
  15. 青岛海尔供应商java面试_青岛某企业面试题(2019-11)
  16. python中元组前代*是什么意思
  17. 什么是外汇套期保值?套期保值和对冲有什么区别?
  18. 新论文 | 基于CATIA的线性工程BIM模型漫游功能开发
  19. POJ 3126 - Prime Path + Python(BFS)
  20. 威海职业学院与云哟科技联合 树“新基建”电竞教育行业新标杆

热门文章

  1. php代码审计(适合小白入门)
  2. iOS修改生成的APP名称
  3. 道路千万条,转行第一条。材料不劝退,亲人两行泪。
  4. mysql查看列名_MySQL:从查询中获取列名或别名
  5. python 数字索引转excel列名
  6. 报表生成器FastReport .Net如何存储和加载报告
  7. python网络测速_Linux下3种常用的网络测速工具
  8. 第七周-C语言 求方程的共轭复根
  9. centos 6.5 thinkpad trackpoint 中间键 滚动设置
  10. lpush rpush 区别_lpush(lpush和rpush)