CodeGuru
Earthweb Search
Login Forums Wireless Jars Gamelan Developer.com
CodeGuru Navigation
RSS Feeds

RSSAll

RSSVC++/C++

RSS.NET/C#

RSSVB

See more EarthWeb Network feeds

follow us on Twitter

Member Sign In
User ID:
Password:
Remember Me:
Forgot Password?
Not a member?
Click here for more information and to register.

Become a Marketplace Partner

jobs.internet.com

internet.commerce
Partners & Affiliates
















Home


Histogram control
Rating: none

Ken C. Len (view profile)
August 5, 1998


(continued)




histogram control  Download Source Code and Example


This custom control displays a left scrolling spike with range configurable by calling SetRange(0,100), the first parameter is the min(bottom) value and the second parameter is max(top) value.

The control is designed to work just like the progress control but with a twist. Every SetPos() will shows a spike and the next SetPos() will scroll the previous one to the left.

The CHistogramCtrl class is derived from CWnd, the header and code are in HistogramCtrl.h and HistogramCtrl.cpp files.

Important

In your dialog box, you must create the control as static control (use "picture" from control toolbar). You must set the properties to

  • Type: Rectangle, and
  • Color: black. (I think black background looks better)

Don't worry about the height, width and border, the control will ajust itself and draw the border for you.

First add a member to your dialog class like this:

class CHistogramTestDlg : public CDialog
{
...
// Implementation
protected:
	CHistogramCtrl m_HistogramCtrl;
...
};

And in the initial dialog box...

BOOL CHistogramTestDlg::OnInitDialog()
{
	CDialog::OnInitDialog();
	...

	CRect rect;
	GetDlgItem(IDC_STATIC_HISTOGRAM)->GetWindowRect(rect);
	ScreenToClient(rect);

	m_HistogramCtrl.Create(WS_VISIBLE | WS_CHILD, rect, this, 100);
	m_HistogramCtrl.SetRange(0,100);

	return TRUE;  // return TRUE  unless you set the focus to a control
}

And the rest use SetPos(UINT nValue).

The custom control uses unique painting technique which is a little bit to long to discuss here. If you want to understand more please email your FAQ to klen@bellatlantic.net thanks. (The code is not as long to read)

Here is an example of how an application looks like with the control.

histogram control

Last updated: 17 May 1998

Tools:
Add www.codeguru.com to your favorites
Add www.codeguru.com to your browser search box
IE 7 | Firefox 2.0 | Firefox 1.5.x
Receive news via our XML/RSS feed







RATE THIS ARTICLE:   Excellent  Very Good  Average  Below Average  Poor  

(You must be signed in to rank an article. Not a member? Click here to register)

Latest Comments:
How to setup Histogram code in Visual C++ 6.0 - ringram2077 (02/14/2007)
Another GOOD GDI example - Legacy CodeGuru (03/10/2003)
Control in Task Manager - Legacy CodeGuru (12/09/2001)
Good job! - Legacy CodeGuru (11/04/2001)
How to add code - Legacy CodeGuru (08/01/2001)

View All Comments
Add a Comment:
Title:
Comment:
Pre-Formatted: Check this if you want the text to display with the formatting as typed (good for source code)



(You must be signed in to comment on an article. Not a member? Click here to register)

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers