Click here to Skip to main content
15,892,674 members
Articles / Desktop Programming / MFC
Article

A Ruler Control

Rate me:
Please Sign up or sign in to vote.
3.00/5 (1 vote)
7 Feb 2000 93.8K   1.9K   28   8
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


    Written By
    Netherlands Netherlands
    This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

    Comments and Discussions

     
    General[Help] Transforming this ruler control [modified] Pin
    Mancini26-Dec-07 4:56
    Mancini26-Dec-07 4:56 
    Hello guys, i'm trying to change this fantastic ruler control.This is what i want but i want to change it and C++ is new to me.So what i want to do is instead of a ruler control change it to a timer control bar,just like this but with the timeline.Then you can drag and drop the hour bar just like this.This is to implement in a JSP web applicattion.I want to know how to change de layout and what are the variables to cut or increment.IF someone could help,i would apreciatte very much!!Thanks


    Mancini

    modified on Wednesday, December 26, 2007 11:04:14 AM

    QuestionCan a graph scale be based on your ruler Pin
    31-Dec-01 13:52
    suss31-Dec-01 13:52 
    GeneralProblem in Init(const CRect rect) Pin
    5-Dec-01 21:43
    suss5-Dec-01 21:43 
    GeneralDividing the ruler control Pin
    JCY27-Sep-01 9:14
    JCY27-Sep-01 9:14 
    GeneralProgress Control Pin
    JekYu30-Aug-01 14:14
    JekYu30-Aug-01 14:14 
    GeneralThe code doesn't work. Pin
    5-Nov-00 17:49
    suss5-Nov-00 17:49 
    GeneralRe: The code doesn't work. Pin
    Christian Graus5-Nov-00 22:16
    protectorChristian Graus5-Nov-00 22:16 
    Questionhorizontal, yes - but vertical? Pin
    Frédéric Marion-Poll16-Aug-00 2:38
    sussFrédéric Marion-Poll16-Aug-00 2:38 

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

    Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.