Rating: none
Norm Alomond (view profile) August 6, 1998 |
Download Source Code and Example
Every wanted a static control that behaved like a Visual Basic(yuk!) label control? Well this could be just the thing you might be looking for. The first cut version of this MFC extension class will allow you to change the text, font attributes (weight, underline, size, name), text color, background color and border style.
I've called the simple class CLabel and is simple to use in dialog boxes, just follow this simple instructions.
- Design the dialog box in the normal why.
- Create a OnInitDialog function using the class wizard.
- Add Label.cpp and Label.h to your project.
- #Include <label.h> in your dialog .cpp file.
- Any static controls that need enhancing, give each control a unique ID.
- Assign a member control (CLabel) to each ID using the class wizard.
- In OnInitDialog change a static controls appearing the functions provided. (See Label.h)
API of CLabel
CLabel& SetBkColor(COLORREF crBkgnd) | Set the background colour of the control |
CLabel& SetText(const CString& strText) | Sets the text of the controls |
CLabel& SetTextColor(COLORREF crText) | Sets the text colour of the control |
CLabel& SetFontBold(BOOL bBold) | Toggles the state of the bold attribute of the text in the control |
CLabel& SetFontName(const CString& strFont) | The the fonts face name in the control |
CLabel& SetFontUnderline(BOOL bSet) | Toggles the state of the underline font attribute of the control |
CLabel& SetFontItalic(BOOL bSet) | Toggles the state of the italic font attribute of the control |
CLabel& SetFontSize(int nSize) | Sets the fonts size in points. |
CLabel& SetSunken(BOOL bSet) | Toggles the state of the sunken attribue of the control |
CLabel& SetBorder(BOOL bSet) | Toggles the state of the borders attribute |
CLabel& FlashText(BOOL bSet) | Toggles the state of the text flashing attribute |
CLabel& FlashBackground(BOOL bSet) | Toggles the state of the text flashing attribute |
CLabel& SetLink(BOOL bLink) | Toggles the state of the link attribute (allows label to become internet link) |
CLabel& SetLinkCursor(HCURSOR hCursor) | Sets the cursor for the link. |
Example of CLabel
m_fname.SetFontName("System"); m_fsize.SetFontSize(14); m_uline.SetFontUnderline(TRUE); m_tcolor.SetTextColor(RGB(255,0,0)); m_bcolor.SetBkColor(RGB(0,255,255)); m_italics.SetFontItalic(TRUE); m_bold.SetFontBold(TRUE); m_border.SetBorder(TRUE); m_sunken.SetSunken(TRUE); m_monty.SetFontName("Arial"); m_monty.SetFontSize(12); m_monty.SetTextColor(RGB(255,255,0)); m_monty.SetFontUnderline(TRUE); m_monty.SetBkColor(RGB(0,0,0)); m_monty.SetFontItalic(TRUE); m_monty.SetFontBold(TRUE); m_monty.SetBorder(TRUE); m_monty.SetSunken(TRUE);
Last Updated: May 30 1998
Free Trial: SQL Toolbelt--Get 12 powerful & intuitive tools to burn through SQL Server chores fast!
Could You Use an Extra $30,000 Right Now? Are You a Mobile or Web App Developer? Click here to learn more!
The next generation of Windows—join the conversation.
Build Full Web Applications in 5 Minutes. Learn more.
30-day Trial: Hitachi IT Operations Analyzer software monitors multivendor server, network & storage assets.
'Tech & IT > 프로그래밍' 카테고리의 다른 글
XML Reader만들기 (0) | 2009.07.26 |
---|---|
[C++] 안전문자열 함수 관련 자료 (0) | 2009.07.14 |
CStdioFile: GetPosition, Seek 질문답변 (0) | 2009.05.22 |
COM/ATL 관련 tip (0) | 2009.04.27 |
COM Versioning관련해서 알아볼 것 (0) | 2009.02.18 |