Solved

Ruler on form

Posted on 1999-01-11
2
326 Views
Last Modified: 2010-05-03
I would like to put scalable rulers at the top and left edge of a form. When the mouse moves an indication is given of position on the ruler. Is there code, control - preferably free that will do this?
0
Comment
Question by:capel
2 Comments
 
LVL 4

Expert Comment

by:chabaud
ID: 1455478
You could draw your rulers in pictureboxes.

Try create a form with one picturebox (use as top ruler):

Option Explicit

Private pos As Integer

Private Sub Form_Load()

    Dim i As Integer
   
    ScaleMode = vbPixels
    Picture1.Align = vbAlignTop
    Picture1.ScaleMode = vbPixels
    Picture1.AutoRedraw = True
    Picture1.width=350
    Picture1.DrawMode = vbCopyPen
   
    For i = 0 To 150
        If i Mod 10 Then
            Picture1.Line (3 * i, 0)-Step(0, 5)
        Else
            Picture1.CurrentX = 2 + 3 * i
            Picture1.CurrentY = 8
            Picture1.Print CStr(i \ 10)
            Picture1.Line (3 * i, 0)-Step(0, 10)
        End If
    Next
    Picture1.DrawMode = vbInvert
    Picture1.Line (pos, 0)-Step(1, 20), , BF
    Picture1.DrawMode = vbCopyPen
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Picture1.DrawMode = vbInvert
    Picture1.Line (pos, 0)-Step(1, 20), , BF
    pos = X
    Picture1.Line (pos, 0)-Step(1, 20), , BF
    Picture1.DrawMode = vbCopyPen
End Sub

0
 
LVL 1

Accepted Solution

by:
Johnn earned 100 total points
ID: 1455479
Then have a line control in each ruler and in the mousemove event move this line to the apropriate location within the ruler
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now