With The Case Of  Release The Power OF  Visual C++ !   HomeProducts | PurchaseSupport | Downloads  
View in English
View in Japanese
View in
View in Franšais
View in Italiano
View in 中文(繁體)
Download Evaluation
Pricing & Purchase?
E-XD++Visual C++/ MFC Products
Features Tour 
Electronic Form Solution
Visualization & HMI Solution
Power system HMI Solution
CAD Drawing and Printing Solution

Bar code labeling Solution
Workflow Solution

Coal industry HMI Solution
Instrumentation Gauge Solution

Report Printing Solution
Graphical modeling Solution
GIS mapping solution

Visio graphics solution
Industrial control SCADA &HMI Solution
BPM business process Solution

Industrial monitoring Solution
Flowchart and diagramming Solution
Organization Diagram Solution

Graphic editor Source Code
UML drawing editor Source Code
Map Diagramming Solution

Architectural Graphic Drawing Solution
Request Evaluation
ActiveX COM Products
Technical Support
  General Q & A
Discussion Board
Contact Us


Get Ready to Unleash the Power of UCanCode .NET

UCanCode Software focuses on general application software development. We provide complete solution for developers. No matter you want to develop a simple database workflow application, or an large flow/diagram based system, our product will provide a complete solution for you. Our product had been used by hundreds of top companies around the world!

"100% source code provided! Free you from not daring to use components because of unable to master the key technology of components!"

VC++ Article: Skin based slider control, CSliderCtrl

 By Ashok Jaiswal

Dress your slider control smart 

Sample Image - skinslider.gif


Here is a solution for developers looking for a skin based slider control. It is different from the article Transparent Slider Control by Nic Wilson in the way that it allows you to skin the background and tick of the slider control and also allows you to have a customized cursor over the slider control.
The main class for slider control is CZipSliderCtl that uses another bitmap class CZipBitmap for drawing normal and transparent images on the control. It is very easy to use and looks good (if you have good-looking images), so go for it. Follow the following instructions to use it  in your application.

How to use it?

Its fairly simple to use the CZipSliderClt class. Just add the files ZipSliderCtl.h, ZipSliderCtl.cpp, ZipBitmap.h, ZipBitmap.cpp into your project, add the slider control to your dialog box and change the member variable of the control. Modify the following code

CSliderCtl	m_sliderCtl;

to look like this:

CZipSliderCtl	m_sliderCtl;

You will need add the following code at the top of you application's dlg header file.

#include "ZipSliderCtl.h"

Congratulations you have successfully created the object of the slider control and now it is time to skin the control. Add the following code at the bottom of OnInitDialog function


So you have skinned your control and it is ready to use. Compile and run to see how it looks. All the best.. enjoy!!!

Behine the scenes

The CZipSliderCtl class is based on the fairly simple concept of subclassing. I have derived this class from CSliderCtl and have overridden the following functions

	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	afx_msg void OnPaint();
	afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
	afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
	afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);

I have used the class CZipBitmap to draw the normal and transparent images on the dialog box. If any transparent image is drawn using this class, it makes all the portions of let-top pixel color transparent. The magic of skinning the control is always contained in the OnPaint function. So look at the following magical lines of code

	CPaintDC dc(this); // device context for painting

	int iMax,iMin,iTickWidth=10,iMarginWidth=10;
	RECT rcBack,rcTick;
	rcTick = rcBack;
	rcTick.left = ((rcBack.right-iMarginWidth)*(GetPos()))/((iMax - iMin)+iMarginWidth/2);
	rcTick.right = rcTick.left + iTickWidth;

	m_bmTrans->DrawTrans(dc,rcTick.left, -2);

so its all done. I hope my efforts will be appreciated



Copyright ?1998-2022 UCanCode.Net Software , all rights reserved.
Other product and company names herein may be the trademarks of their respective owners.

Please direct your questions or comments to