![]() |
Desktop Development »
Miscellaneous »
Miscellaneous Controls
Intermediate
License: The Code Project Open License (CPOL)
XGradientZoneBar - an MFC color gradient indicator barBy Hans DietrichXGradientZoneBar displays an indicator bar that allows you to specify multiple zones that are filled with a color gradient, and includes APIs to set the bar orientation, font, and tick marks. |
C++ (VC6, VC8.0), Windows, Visual Studio (VS2005), MFC, Dev
|
||||||||||
|
Advanced Search |
|
|
||||||||||||||||||
|
Winner April 2008 Monthly Competition |
To get an idea of what XGradientZoneBar can be used for, click on Demo button:
| Function | Description |
|---|---|
| COLORREF GetBackgroundColor() | Retrieves background color |
| CXGradientZoneBar& SetBackgroundColor(COLORREF cr, BOOL bRedraw = TRUE) | Sets background color |
| void GetBarInfo(XGRADIENT_ZONE_BAR_INFO *pXZBI); | Retrieves XGRADIENT_ZONE_BAR_INFO struct for bar |
| CXGradientZoneBar& SetBarInfo(XGRADIENT_ZONE_BAR_INFO *pXZBI); | Sets bar options via XGRADIENT_ZONE_BAR_INFO struct |
| ORIENTATION GetBarOrientation() | Retrieves bar orientation (HORIZONTAL or VERTICAL) |
| CXGradientZoneBar& SetBarOrientation(ORIENTATION eOrientation, BOOL bRedraw = TRUE) | Sets bar orientation (HORIZONTAL or VERTICAL) |
| BOOL GetBold(); | Retrieves bold setting |
| CXGradientZoneBar& SetBold(BOOL bBold, BOOL bRedraw = TRUE); | Sets bold font |
| CString GetFontFaceName(); | Retrieves font face name |
| int GetFontPointSize(); | Retrieves font point size |
| CXGradientZoneBar& SetFont(LPCTSTR lpszFaceName, int nPointSize, BOOL bRedraw = TRUE); | Sets font face name and point size |
| BOOL GetFont(LOGFONT *pLF); | Retrieves LOGFONT struct for font |
| CXGradientZoneBar& SetFont(LOGFONT * pLogFont, BOOL bRedraw = TRUE); | Sets font via LOGFONT struct |
| CFont* GetFont() | Retrieves pointer to CFont member variable |
| CXGradientZoneBar& SetFont(CFont *pFont, BOOL bRedraw = TRUE); | Sets font via CFont object |
| int GetMaxPercent() | Retrieves max percent fill |
| CXGradientZoneBar& SetMaxPercent(int nMaxPercent, BOOL bRedraw = TRUE) | Set percent of gradient fill to show; remainder will be filled with background color |
| CString GetText() | Retrieves bar text |
| CXGradientZoneBar& SetText(LPCTSTR lpszText, BOOL bRedraw = TRUE) | Sets bar text |
| TEXTALIGNHORIZONTAL GetTextAlignHorizontal() | Retrieves bar text horizontal alignment (LEFT, RIGHT, CENTER) |
| CXGradientZoneBar& SetTextAlignHorizontal(TEXTALIGNHORIZONTAL eAlign, BOOL bRedraw = TRUE) | Sets bar text horizontal alignment (LEFT, RIGHT, CENTER) |
| TEXTALIGNVERTICAL GetTextAlignVertical() | Retrieves bar text vertical alignment (TOP, BOTTOM, VCENTER) |
| CXGradientZoneBar& SetTextAlignVertical(TEXTALIGNVERTICAL eAlign, BOOL bRedraw = TRUE) | Sets bar text vertical alignment (TOP, BOTTOM, VCENTER) |
| COLORREF GetTextColor() | Retrieves text color |
| CXGradientZoneBar& SetTextColor(COLORREF cr, BOOL bRedraw = TRUE) | Set text color |
| UINT GetTextOrientation() | Retrieves text orientation (0, 90 or 270) |
| CXGradientZoneBar& SetTextOrientation(UINT nTextOrientation, BOOL bRedraw = TRUE); | Sets text orientation (0, 90 or 270) |
| COLORREF GetTickColor() | Retrieves tick color |
| CXGradientZoneBar& SetTickColor(COLORREF cr, BOOL bRedraw = TRUE) | Sets tick color |
| UINT GetTicksPerZone() | Retrives number of ticks per zone |
| CXGradientZoneBar& SetTicksPerZone(UINT nTicksPerZone, BOOL bRedraw = TRUE) | Sets number of ticks per zone |
| void GetTickSizes(UINT& nUnitTick, UINT& n10thTick) | Retrieves tick sizes |
| CXGradientZoneBar& SetTickSizes(UINT nUnitTick, UINT n10thTick, BOOL bRedraw = TRUE) | Sets tick sizes |
| TICKMARKTYPE GetTickType() | Retrieves tick type (NOTICKMARKS, TOP_LEFT, BOTTOM_RIGHT, BOTH, BOX) |
| CXGradientZoneBar& SetTickType(TICKMARKTYPE eTickMarkType, BOOL bRedraw = TRUE) | Sets tick type (NOTICKMARKS, TOP_LEFT, BOTTOM_RIGHT, BOTH, BOX) |
| CString GetToolTipText() | Retrieves tooltip text |
| CXGradientZoneBar& SetToolTipText(LPCTSTR lpszText, BOOL bRedraw = TRUE) | Sets tooltip text |
| TOOLTIPTYPE GetToolTipType() | Retrieves tooltip type (NOTOOLTIP, TEXT_TOOLTIP, PERCENT_TOOLTIP, TEXT_PERCENT_TOOLTIP, PERCENT_TEXT_TOOLTIP) |
| CXGradientZoneBar& SetToolTipType(TOOLTIPTYPE eType, BOOL bRedraw = TRUE) | Sets tooltip type (NOTOOLTIP, TEXT_TOOLTIP, PERCENT_TOOLTIP, TEXT_PERCENT_TOOLTIP, PERCENT_TEXT_TOOLTIP) |
| CXGradientZoneBar& SetZones(UINT nZones, XGRADIENT_ZONE *pZones, BOOL bRedraw = TRUE); | Sets gradient bar zones |
Text![]() |
Percent![]() |
Text + Percent![]() |
Percent + Text![]() |
CFormView or
CPropertyPage.
To integrate CXGradientZoneBar into your app, you first need to
add following files to your project:
Note that this step is not required, if you have some other way to specify where XGradientZoneBar should be displayed.
#include statement to dialog class header file:
#include "XGradientZoneBar.h"and insert variable that looks like:
CXGradientZoneBar m_GradientZoneBar;
Second, add code to OnInitDialog() function:
CRect rect;
GetDlgItem(IDC_STATIC_BAR1)->GetWindowRect(&rect);
ScreenToClient(&rect);
GetDlgItem(IDC_STATIC_BAR1)->ShowWindow(SW_HIDE);
VERIFY(m_GradientZoneBar.Create(AfxGetInstanceHandle(), 0,
WS_CHILD | WS_VISIBLE, rect, this, IDC_BAR1));
m_Bar1.SetBarOrientation(CXGradientZoneBar::VERTICAL, FALSE)
.SetText(_T("Bar1"), FALSE)
.SetTextAlignVertical(CXGradientZoneBar::TOP)
.SetTextColor(RGB(0,255,0))
.SetFont(_T("Times New Roman"), 18, FALSE)
.SetTextOrientation(90, FALSE)
.SetZones(_countof(GreenToRed), GreenToRed, FALSE)
.SetTickType(CXGradientZoneBar::TOP_LEFT, FALSE)
.SetToolTipText(_T("This is Bar1"), FALSE)
.SetToolTipType(CXGradientZoneBar::TEXT_TOOLTIP, FALSE)
.SetBackgroundColor(RGB(0,0,0))
.SetMaxPercent(50);
Here are links to my articles on CodeProject, which I have used in demo app:
This software is released into the public domain. You are free to use it in any way you like, except that you may not sell this source code. If you modify it or extend it, please to consider posting new code here for everyone to share. This software is provided "as is" with no expressed or implied warranty. I accept no liability for any damage or loss of business that this software may cause.
| You must Sign In to use this message board. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 19 May 2008 Editor: |
Copyright 2008 by Hans Dietrich Everything else Copyright © CodeProject, 1999-2009 Web17 | Advertise on the Code Project |