Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

A Ruler Control

0.00/5 (No votes)
7 Feb 2000 2  
A simple ruler control to allow users to set margins or indents
  • Download source files - 21 Kb
  • Sample Image - RulerCtrl.jpg

    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).

    License

    This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

    A list of licenses authors might use can be found here