Results 1 to 7 of 7

Thread: Mouse move event (Screensaver)

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2000
    Location
    Malaysia
    Posts
    69
    How do I put a mousemove or a keypress event on the code that doesn't have to be focus on specific controls so that I can invoke the event no matters when I am and which controls I focus on ?

    How do I keep track the position of my mouse on the screen in code like the x,y coordinates ?

  2. #2
    Frenzied Member Buzby's Avatar
    Join Date
    Jan 1999
    Location
    UK
    Posts
    1,670
    If you set the form's KeyPreview property to TRUE the form's KeyPress event gets called before whatever control has the focus gets told about it.

    'Buzby'
    Visual Basic Developer
    "I'm moving to Theory. Everything works there."

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Mar 2000
    Location
    Malaysia
    Posts
    69
    How about mousemove event ?

  4. #4
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    India
    Posts
    298

    old post - rediscovered

    Hi,

    was searching for posts about screensavers when I came across this post.

    I have a form with an Image control on it. Im trying to create a basic screensaver with this. My problem was that my app unloads only if the mouse is moved over the form.

    If you set the form's KeyPreview property to TRUE the form's KeyPress event gets called before whatever control has the focus gets told about it.

    Is there a similar sort of thing for the mouse????

    Thanx.

  5. #5
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    India
    Posts
    298
    exactly trisLOGIC!

    forget about that event! thanx anyway! :-)

  6. #6
    Guest
    Q1:

    Set the Timer's interval to 1.

    Code:
    Private Declare Function GetAsyncKeyState _
    Lib "user32" (ByVal vKey As Long) As Integer
    
    Private Sub Timer1_Timer()    
    Dim iKey As Integer    
    For iKey = 0 To 255       
    If GetAsyncKeyState(iKey) Then Debug.Print iKey 
    'detects key presses and mouse clicks 
    Next 
    End Sub


    Q2:

    Code:
    Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Debug.Print X, Y
    End Sub

  7. #7
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    If you're using image controls or picture boxes in your screensaver form then just set there enable property to False.
    Then the mouse move event will still be raised for the form even if the mouse is over an image.

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