Chinaunix首页 | 论坛 | 博客
  • 博客访问: 627964
  • 博文数量: 603
  • 博客积分: 4000
  • 博客等级: 上校
  • 技术积分: 4940
  • 用 户 组: 普通用户
  • 注册时间: 2008-09-17 11:04
文章分类

全部博文(603)

文章存档

2011年(1)

2008年(602)

我的朋友

分类:

2008-09-17 11:17:02



摘要
  此代码用来为SDI程序快速的加入一个漂亮的标题窗口,代码是不难,属于初级水平。在源代码中有一些注释,即使是对于初学者也很容易明白。这个标题窗口支持不同颜色的文字,文字阴影,背景,字体的尺寸和类型,字体在窗口中的位置等。同时也支持背景的渐变色背景。

代码的使用
  CHeaderToolbar类从CToolBar类派生,当你创建一个工具条时,重要的调用SetDrawRect(Rect)函数,演示如下:

  CRect Size;

  Size.SetRect(0,0,0,30);

  if (!m_headerdefault.CreateEx(this, TBSTYLE_TRANSPARENT , WS_CHILD | WS_VISIBLE | CBRS_TOP, Size))
  {
    TRACE0("Failed to create headern");
  }

  //The rect is transparent, until you set the drawrect...
  m_headerdefault.SetDrawRect(Size);
rect只用来设置高度。如果成功创建,将得到一个具有默认颜色的标题头。为了具有更多的特色,你可以使用下面这些函数: 

  //Background
  void SetDrawRect(CRect Rect); //Required, or else the toolbar is transparent
  void SetGradient(BOOL Activate); //TRUE OR FALSE
  void SetGradientStartColor(COLORREF GradientStart); //This also sets the default color when gradient is off
  void SetGradientEndColor(COLORREF GradientEnd); //End gradient color

  //Text
  void SetWindowText(CString InputText); //Outputtext on screen
  void GetWindowText(CString &OutputText); //Returns current text
  void SetFont(CString FontName); //Set the font name (as text)
  void SetFontSize(int NewSize); //Set the point-size
  void SetTextCol(COLORREF Col); //Set the text color
  void SetTextShadowCol(COLORREF Col); //Sets the color of the shadow
  void SetPlaceMent(int Place); //DT_LEFT, DT_CENTER and DT_RIGHT is available options. (MSDN: CDC -> DrawText())
每一次你使用不同的函数为标题头设置不同的风格,标题头都会刷新一次。

--------------------next---------------------

阅读(330) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~