Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Chase Mouse Have 95 Points

Posted on 1999-07-14
6
Medium Priority
?
305 Views
Last Modified: 2011-09-20
Hi, looking for code that will make a form chase the mouse. In other words, like where ever you move your mouse the form will follow. Working code please. Have 95 points or would offer more.
ssi49
0
Comment
Question by:ssi49
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 2

Expert Comment

by:BeedleGuis
ID: 1524799
will code to clip, or keep the mouse in the form work?? Thats alot easier than making the form chase the mouse.
0
 
LVL 1

Accepted Solution

by:
Maquiavelo earned 360 total points
ID: 1524800
 Hi! I've tried this code and seems to work.

  Hope it helps...

Paste this to BAS

Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long

Type POINTAPI
        x As Long
        y As Long
End Type

Add a timer control to the form, and paste the following code,

Private Sub Timer1_Timer()
    Dim a As POINTAPI
    Dim b As Long, c As Long
    Dim res&
   
    res& = GetCursorPos(a)
    Me.Move a.x * 10, a.y * 10
End Sub

  See ya...
0
 

Author Comment

by:ssi49
ID: 1524801
Maquiavelo
Thanks for the code. I am using vb 5.0 and when i run the program, the form doesn't do anything ? I move the mouse but the form just sits there. I pasted everything correctly. Any suggestions ?
Thanks
ssi49
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Expert Comment

by:michelv
ID: 1524802
Be sure to set the timer interval to something other than 0, when 0 no timer events occur, interval = 1000 = 1 sec timer interval. So in this case, you may want to set the interval to 10:

timer1.interval = 10
timer1.enabled = true

Have you also pasted the sub Timer1_Timer into form1 (not into Module1)?

Also the me.move statement should be like this:

Me.Move a.x * Screen.TwipsPerPixelX, a.y * Screen.TwipsPerPixelY

Hope this helps...


0
 

Author Comment

by:ssi49
ID: 1524803
Works Real Nice, Thank You !
0
 
LVL 1

Expert Comment

by:Maquiavelo
ID: 1524804
 Thanks michaelv! I think you deserve some points... :)
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

721 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