Results 1 to 5 of 5

Thread: This is interesting, Please help!

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    ma,usa
    Posts
    485

    Hi,
    I'm trying to use a rubber box to select and I'm left with little spots everywhere on the screen. Because of stuff on the screen I can't use cls. I've exagerated the problem to give you folks a better picture so that you might be able to help me. Please place a command button on the form and put this stuff in the code. I want to make it so the square goes away (obviously).


    Private Sub Command1_Click()
    Line (X1, Y1)-(X2, Y2), , B
    End Sub

    Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    down = True
    X1 = X
    Y1 = Y
    X2 = X
    Y2 = Y
    DrawMode = 6
    DrawWidth = 20
    End Sub

    Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If down = True Then

    Line (X1, Y1)-(X2, Y2), , B
    X2 = X
    Y2 = Y
    Line (X1, Y1)-(X2, Y2), , B
    End If
    End Sub

    Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    down = False
    End Sub

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    Just add a line in the MouseDown event:
    Code:
    Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
        down = True
        x1 = X
        y1 = Y
        x2 = X
        y2 = Y
        DrawMode = 6
        DrawWidth = 20
        Line (x1, y1)-(x2, y2), , B 'add this line here
    End Sub

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    ma,usa
    Posts
    485
    Thanks!!!
    Don't know why it worked but it did! Thanks!

  4. #4
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    The reason it works is that you have set the DrawMode to 6 - Invert.
    In the MouseMove event you draw the box twice. The first time it deletes the old box and the you set the new values to X2 and Y2 and draw the new box.
    Now consider this senario:
    You first press down the mouse at the point (10, 20) this will couse the MouseDown event to fire and initiate the X1, Y1, X2 and Y2 variables. Now you move the mouse to the point (12, 23) witch will couse the MouseMove event to fire. This procedure will first draw a box at the points (10, 20) - (10, 20) and then set the X2 and Y2 variables to 12 and 23 respectively and draw a new box at (10, 20) - (12, 23) but since there allready is a box drawn at the older position this will disappear.
    When you click on the button it will draw the same box again in a invert mode witch will couse the box to disappear except for the point that allready is gone. This point will be drawn again.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    ma,usa
    Posts
    485
    Thanks for the insight. I think it's great not only being able to do new things, but to understand them as well.
    Thanks Again,
    Joey O

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