Click here to Skip to main content
Click here to Skip to main content

Transparent CSliderCtrl Class

By , 14 Nov 2002
 

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)

About the Author

Nic Wilson
Web Developer
Australia Australia
Member
No Biography provided

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralDoesn't work with CScrollViewmemberhoxsiew27 Mar '07 - 10:13 
I'm trying to create this on the fly in a CScrollView derived class as part of a SDI application. I suspect that the scroll view or it's base CWnd is eating the notify messages, but I can't be sure. Spy++ on your demo shows WM_NOTIFY messages sent to the parent (CDialog) but the same control instantiated as a child of the scroll view doesn't seem to be sending WM_NOTIFY messages to the parent at all. Without WM_NOTIFY, the parent can't send a reflected message.
 
Any clues?
GeneralTransparent Controlmemberarijit_datta268 Mar '07 - 20:41 
Hi,
I am trying to develop a transparent control.It is having a picture box with a png image and transparent background.I have set the background color of the control to transparent.
Now, it is working if I place it on a panel or a form. But, it is not working as a transparent control if I place it on another control such as list view or month calender.
If some body can help me,I would be thankful to him.
Generalpocket pc applicationmemberjstanna11 Feb '05 - 5:57 
While trying to apply this to a pocket pc program, it compiled right away without a problem, but the transparent background didn't work. As I worked with it, it would either have a white or grey background behind the slider, or if I commented out the line in the beginning of DrawChannel for ScreenToClient, that was the only time I got something of the original bitmap to show up, but it was the rectangle beginning immediately below the slider instead of where the slider was. I was able to get a custom thumb bitmap to show up fine, but only for a horizontal slider. Absolutely nothing works for a vertical slider. Any ideas?
 
Jennifer
GeneralProblem with the resizing windowsmemberAtif Mushtaq30 May '04 - 23:14 
in case of resizing window ,if initially some part of slider is hidden and then u resize it , it wont get drawn properly.
 
Unmanaged in a .NET world
GeneralRe: Problem with the resizing windowsmemberranxiaowu12 Dec '12 - 19:44 
i met the same problem,when i resize the slider control,transparent not work.
hello,every one.

GeneralProblem with the backgroundmemberOlaf Gramkow5 Nov '03 - 10:43 
When I start the demo and another program (for example the explorer) is in front of the demo program (the demo program will be displayed behind the other program), the background of the slider have a wrong background. The background behind the slider has the backgroud of the window, which was in the front of the demo program, when I startet the demo program. Any ideas how to fix this problem?
 
You want to test it?
Start the Windows Task-Manager and place the window in the middle of the Desktop. Now start the demo program, it will appear behind the Task-Manager. Then close the Task-Manager and you will see the problem.
 
Olaf
GeneralRe: Problem with the backgroundmembermalcolm clarke17 Jul '05 - 10:32 
was a solution for this found, I like the control minus this bug Frown | :(
GeneralChanging the background of the slidermemberManju16 Jul '03 - 21:17 
Hi,
 
I am not familiar with the things explained in the article. But I would like to have the slider having the same background color as its parent window. How can I do that? I don't want to change the thumb or anything. Can someone help me how to do this?
 
Thanks
Manju
GeneralDrawTransparent() questionmemberHarold Bamford21 Nov '02 - 8:37 
Nic,
 
Another dumb question for you. In DrawTransparent() you have the following:
	Invalidate();
	EnableWindow(FALSE);
	EnableWindow(TRUE);
I don't understand what is happening here. What do the pair of EnableWindow() calls do that Invalidate() doesn't? The documentation for EnableWindow() seems to indicate that this is for controlling mouse and keyboard input rather than drawing.
 
Thanks for the help!
GeneralRe: DrawTransparent() questionmemberNic Wilson21 Nov '02 - 11:13 

Hi,
 
This is the only way I have found to make sure a full set of paint messages are sent, mainly needed for the users who need to change backgrounds with transparent controls.
 
Nic

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

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