A Ruler Control





3.00/5 (1 vote)
Feb 8, 2000

94441

1861
A simple ruler control to allow users to set margins or indents
Introduction
CRulerSlider is a control derived from CProgressCtrl. The Control replicates the behaviour of the ruler bar in many wordprocessor applications, and allows the user to click and drag the left and right edges to set values for such things as margins and indents. The code for the control is in the RulerSlider.cpp and RulerSlider.h files.
To use...
Using the control is as simple as using any other derived control. Simply place a progress control onto a dialog or form and subclass is using the Wizards. Alternatively, you can create the control dynamically. For example:
CRect rc = CRect(10,80,300, 100); CRulerSlider slider; slider.Create(WS_CHILD|WS_VISIBLE|PBS_SMOOTH| WS_TABSTOP , rc, this, 2);
The control has only two properties:
int GetLeftPos() int GetRightPos()
These get the size of the left and right margins (always greater than or equal to 0).