Results 1 to 6 of 6

Thread: How to?

  1. #1

    Thread Starter
    Addicted Member Mih_Flyer's Avatar
    Join Date
    Mar 2000
    Location
    some place there
    Posts
    241

    Exclamation

    hello
    I have a line inside a picture box, and i want to know when the mouse clicked at that line? what code should i use?? this line is not a line from line method, it is a line from the line control. please help me
    Thanx

  2. #2
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Bellevue, WA, USA
    Posts
    1,357
    Since a line isn't like a normal control, when your mouse moves over the line, it really triggers the Form_MouseMove Event.

    The line does have an X1, X2, Y1, and Y2 properties, which can be compared to the x and y coordinates of the mouse. The X1 and Y1 coordinates determine the line's leftmost point, and the X2 and Y2 coordinates determine the line's rightmost point.

    By determining if the x and y coordinates of the mouse are contained within the coordinates of the line, you know when the mouse is over the line. Put code in the Form_MouseDown event and check the position to capture when a user clicks on the line.

    I know you can figure it out, but here's a little sample program to see the relationship between the mouse and the line:

    Drop 6 labels on your form, big enough to display "Line X1 = 999", and then draw a line on the form. Leave the default control names.

    Place the following code into the form's code window:
    Code:
    Option Explicit
    
    Private Sub Form_Load()
        Label1 = "Line x1 = " & Line1.X1
        Label2 = "Line x2 = " & Line1.X2
        Label3 = "Line y1 = " & Line1.Y1
        Label4 = "Line y2 = " & Line1.Y2
    End Sub
    
    Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
        Label5 = "Mouse x = " & X
        Label6 = "Mouse y = " & Y
    End Sub
    Now move the mouse around and compare the x,y coordinates of the mouse to the coordinates of the line (they are all displayed for you). Stop the program and move the line around (make it diagonal). You will get the idea.

    [Edited by seaweed on 06-19-2000 at 09:56 PM]
    ~seaweed

  3. #3
    Lively Member
    Join Date
    Jun 2000
    Posts
    67
    Hmmm well ofcourse you can do what the guy before me said but you could always make a line with paint and put it in and then do picline1_click

    I wish i thought of that when i had that problem

  4. #4

    Thread Starter
    Addicted Member Mih_Flyer's Avatar
    Join Date
    Mar 2000
    Location
    some place there
    Posts
    241

    Red face

    Ok thanx guys, but any one has a code, i want that code please just to check the mouse if its over the line,,
    Thanx

  5. #5

    Thread Starter
    Addicted Member Mih_Flyer's Avatar
    Join Date
    Mar 2000
    Location
    some place there
    Posts
    241

    Talking Thanx Mate

    Thanx aot mate, and what is the relation between med and math????
    there is no realtion, i know every thing about bodies specially dead ones, and drugs and other ****, but i don't know **** about math, actually i hate it some times, any way thanx alot

  6. #6
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Bellevue, WA, USA
    Posts
    1,357

    Smile You're welcome

    Well, I guess you take more science and stuff than math. I was just hoping you knew it because I wasn't sure I would remember it. It came back pretty quickly, though.

    ~seaweed

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width