Click here to Skip to main content
11,712,802 members (84,052 online)
Click here to Skip to main content

Transparent CSliderCtrl Class

, 14 Nov 2002 CPOL 115K 7.4K 45
Rate this:
Please Sign up or sign in to vote.
A MFC Transparent CSliderCtrl class

sliders.jpg

Introduction

This is a MFC transparent slider class. As it uses CSliderCtrl as its base class it can be used as a replacement class for any CSliderCtrl object. Tic marks are fully supported as can be seen in the screen shot above. To use, add this class to your project. Add your sliders to your project normally, then change the CSliderCtrl type in your .h file to CMySliderControl and #include the MySliderControl.h file. Once compiled your sliders will be transparent and if you have auto tics set then these too will show.

Update

V2.0 Re-wrote parts of the class. Added the ability to redraw the controls when the backgrounds had changed. Added custom transparent channel and custom thumb with optional colours. The demo source has been updated to show the background changing.

License

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

Share

About the Author

Nic Wilson
Web Developer
Australia Australia
No Biography provided

You may also be interested in...

Comments and Discussions

 
GeneralDoesn't work with CScrollView Pin
hoxsiew27-Mar-07 10:13
memberhoxsiew27-Mar-07 10:13 
GeneralTransparent Control Pin
arijit_datta268-Mar-07 20:41
memberarijit_datta268-Mar-07 20:41 
Generalpocket pc application Pin
jstanna11-Feb-05 5:57
memberjstanna11-Feb-05 5:57 
GeneralProblem with the resizing windows Pin
Atif Mushtaq30-May-04 23:14
memberAtif Mushtaq30-May-04 23:14 
GeneralRe: Problem with the resizing windows Pin
ranxiaowu12-Dec-12 19:44
memberranxiaowu12-Dec-12 19:44 
GeneralProblem with the background Pin
Olaf Gramkow5-Nov-03 10:43
memberOlaf Gramkow5-Nov-03 10:43 
GeneralRe: Problem with the background Pin
malcolm clarke17-Jul-05 10:32
membermalcolm clarke17-Jul-05 10:32 
GeneralChanging the background of the slider Pin
Manju16-Jul-03 21:17
memberManju16-Jul-03 21:17 
GeneralDrawTransparent() question Pin
Harold Bamford21-Nov-02 8:37
memberHarold Bamford21-Nov-02 8:37 
GeneralRe: DrawTransparent() question Pin
Nic Wilson21-Nov-02 11:13
memberNic Wilson21-Nov-02 11:13 
GeneralRe: DrawTransparent() question Pin
Harold Bamford22-Nov-02 8:05
memberHarold Bamford22-Nov-02 8:05 
GeneralRe: DrawTransparent() question Pin
David Cole30-Jul-04 7:00
memberDavid Cole30-Jul-04 7:00 
AnswerRe: DrawTransparent() question Pin
dhclark3-Nov-10 8:11
memberdhclark3-Nov-10 8:11 
QuestionBetter way to know vertical from horizontal? Pin
Harold Bamford20-Nov-02 17:27
memberHarold Bamford20-Nov-02 17:27 
In your code for DrawChannel(), you ask if there is a better way to determine if the control is vertical or horizontal. Try:

	// get channel orientation
	BOOL IsVertical = (TBS_VERT & GetStyle()) ? TRUE : FALSE;
Having said that, I have GOT to ask what this is all about:
	crect = lpcd->rc;
	if (IsVertical)
		crect.InflateRect(1, 0, 1, 0);
	else
		crect.InflateRect(0, 2, 0, 2);
	DrawEdge(pDC->m_hDC, &crect, EDGE_SUNKEN, BF_RECT | BF_ADJUST);
It looks like the goal of DrawChannel() is merely to capture the background bitmap and then finish the channel. Wouldn't it be easier to just capture the background in OnCustomDraw() and set
*pResult = CDRF_DODEFAULT;
What have I missed here?

And while I'm asking dumb questions, why do you use the DC for the parent window rather than the current window?

Thanks for your help on this. Obviously, I'm a GDI beginner...Confused | :confused:
AnswerRe: Better way to know vertical from horizontal? Pin
Nic Wilson21-Nov-02 11:18
memberNic Wilson21-Nov-02 11:18 
GeneralChanging the background image Pin
Atlantys22-Sep-02 7:51
memberAtlantys22-Sep-02 7:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150819.1 | Last Updated 15 Nov 2002
Article Copyright 2001 by Nic Wilson
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid