|
在SDI/MDI程序的工具条上加入漂亮的标题头
| 【字体:大
中 小】
|
整理日期:2006-2-18 0:00:00
|
【打印本文】
【收藏此文】 |
下载本文所附源代码 程序运行效果截图:  | 摘要 此代码用来为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()) 每一次你使用不同的函数为标题头设置不同的风格,标题头都会刷新一次。 |
|
|
|
|
|