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

A Ruler Control

, 7 Feb 2000
Rate this:
Please Sign up or sign in to vote.
A simple ruler control to allow users to set margins or indents
  • Download source files - 21 Kb
  • Sample Image - RulerCtrl.jpg

    <!-- Article Starts -->

    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

    Share

    About the Author

    Michael Ang

    Netherlands Netherlands
    No Biography provided

    Comments and Discussions

     
    General[Help] Transforming this ruler control [modified] PinmemberMancini26-Dec-07 4:56 
    QuestionCan a graph scale be based on your ruler PinmemberWill Pittenger31-Dec-01 13:52 
    GeneralProblem in Init(const CRect rect) Pinmemberrdalling5-Dec-01 21:43 
    GeneralDividing the ruler control PinmemberJCY27-Sep-01 9:14 
    GeneralProgress Control PinmemberJekYu30-Aug-01 14:14 
    GeneralThe code doesn't work. PinmemberAnonymous5-Nov-00 17:49 
    GeneralRe: The code doesn't work. PinmemberChristian Graus5-Nov-00 22:16 
    Questionhorizontal, yes - but vertical? PinsussFrédéric Marion-Poll16-Aug-00 2:38 

    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 | Mobile
    Web01 | 2.8.140821.2 | Last Updated 8 Feb 2000
    Article Copyright 2000 by Michael Ang
    Everything else Copyright © CodeProject, 1999-2014
    Terms of Service
    Layout: fixed | fluid