Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

XScrollBar - Scroll bar like Windows Media Player's

, 2 Sep 2008 CPOL
XScrollBar is a scroll bar that may be displayed with optional thumb color, thumb gripper, and channel color
XScrollBar_demo.zip
vs2005
src
app.manifest
res
hans.ico
HorizontalScrollBarChannel.bmp
HorizontalScrollBarLeftArrow.bmp
HorizontalScrollBarRightArrow.bmp
HorizontalScrollBarThumb.bmp
HorizontalScrollBarThumbNoColor.bmp
VerticalScrollBarChannel.bmp
VerticalScrollBarDownArrow.bmp
VerticalScrollBarThumb.bmp
VerticalScrollBarThumbNoColor.bmp
VerticalScrollBarUpArrow.bmp
vs6
Release
XScrollBarTest.exe
XScrollBarTest.dsp
XScrollBarTest.dsw
#include "stdafx.h"
#include "About.h"

#define BACKGROUND_COLOR1	RGB(255,237,210)
#define BACKGROUND_COLOR2	RGB(255,203,125)
#define BACKGROUND_COLOR3	RGB(255,230,190)

#pragma message("automatic link to msimg32.lib")
#pragma comment(lib, "msimg32.lib")		// needed for GradientFill()

//=============================================================================
BEGIN_MESSAGE_MAP(CAboutDlg, ABOUT_BASE_CLASS)
//=============================================================================
	//{{AFX_MSG_MAP(CAboutDlg)
	ON_WM_CTLCOLOR()
	ON_WM_ERASEBKGND()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

//=============================================================================
CAboutDlg::CAboutDlg() : ABOUT_BASE_CLASS(CAboutDlg::IDD)
//=============================================================================
{
	//{{AFX_DATA_INIT(CAboutDlg)
	//}}AFX_DATA_INIT
	m_brush.CreateSolidBrush(BACKGROUND_COLOR3);
}

//=============================================================================
CAboutDlg::~CAboutDlg()
//=============================================================================
{
	if (m_brush.GetSafeHandle())
		m_brush.DeleteObject();
}

//=============================================================================
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
//=============================================================================
{
	ABOUT_BASE_CLASS::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAboutDlg)
	DDX_Control(pDX, IDC_ABOUT_EMAIL, m_ctrlEmail);
	//}}AFX_DATA_MAP
}

//=============================================================================
BOOL CAboutDlg::OnInitDialog()
//=============================================================================
{
	ABOUT_BASE_CLASS::OnInitDialog();
		
	CString strMailTo = _T("");
	strMailTo.LoadString(IDS_MAILTO);

	m_ctrlEmail.SetURL(strMailTo);
	m_ctrlEmail.SetBackgroundColour(BACKGROUND_COLOR2);
	m_ctrlEmail.SetColours(RGB(0,0,255), RGB(0,0,255), RGB(0,0,255));

	CenterWindow();

	return TRUE;
}

//=============================================================================
HBRUSH CAboutDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
//=============================================================================
{
	// must call base class to get hyperlink colors drawn
	HBRUSH hbr = ABOUT_BASE_CLASS::OnCtlColor(pDC, pWnd, nCtlColor);
	 
	if ((pWnd->m_hWnd != GetDlgItem(IDC_HANS)->m_hWnd) && (nCtlColor == CTLCOLOR_STATIC))
	{
		pDC->SetBkMode(TRANSPARENT);      // Set the Background Mode to TRANSPARENT  
		hbr = (HBRUSH) ::GetStockObject(NULL_BRUSH); // return handle to a NULL brush  
	}
	else
	{
		hbr = m_brush;
	}
	return hbr;
}

//=============================================================================
BOOL CAboutDlg::OnEraseBkgnd(CDC* pDC) 
//=============================================================================
{
	CRect rectClient;
	GetClientRect(&rectClient);

#pragma warning(disable : 4310)

	TRIVERTEX vert[2];
	vert[0].x      = 0;
	vert[0].y      = 0;
	vert[0].Red    = (COLOR16) (GetRValue(BACKGROUND_COLOR1) << 8);
	vert[0].Green  = (COLOR16) (GetGValue(BACKGROUND_COLOR1) << 8);
	vert[0].Blue   = (COLOR16) (GetBValue(BACKGROUND_COLOR1) << 8);
	vert[0].Alpha  = 0x0000;

	vert[1].x      = rectClient.right;
	vert[1].y      = rectClient.bottom; 
	vert[1].Red    = (COLOR16) (GetRValue(BACKGROUND_COLOR2) << 8);
	vert[1].Green  = (COLOR16) (GetGValue(BACKGROUND_COLOR2) << 8);
	vert[1].Blue   = (COLOR16) (GetBValue(BACKGROUND_COLOR2) << 8);
	vert[1].Alpha  = 0x0000;

	GRADIENT_RECT rect;
	rect.UpperLeft  = 0;
	rect.LowerRight = 1;

	::GradientFill(pDC->m_hDC, vert, 2, &rect, 1, GRADIENT_FILL_RECT_V);

	return TRUE;
	//return ABOUT_BASE_CLASS::OnEraseBkgnd(pDC);
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Hans Dietrich
Software Developer (Senior) Hans Dietrich Software
United States United States
I attended St. Michael's College of the University of Toronto, with the intention of becoming a priest. A friend in the University's Computer Science Department got me interested in programming, and I have been hooked ever since.
 
Recently, I have moved to Los Angeles where I am doing consulting and development work.
 
For consulting and custom software development, please see www.hdsoft.org.






| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.150327.1 | Last Updated 2 Sep 2008
Article Copyright 2004 by Hans Dietrich
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid