Solved

Mouse Possition

Posted on 2001-06-25
4
125 Views
Last Modified: 2010-05-02
Hi all.
All I need to know is how to get the mouse possition
on the screen.
I am using VB6,and know how to work with the mouse events
in a form or object. But I need a way to find the mouse
possition without writing a code for each form or object
in my program.
I know that the solution will be an API function,but I am
not good in APIs.
Can anybody help?
Thank you
0
Comment
Question by:HESUS
[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
  • 2
4 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 100 total points
ID: 6224150
Private Declare Function DeleteFile Lib "kernel32" Alias "DeleteFileA" (ByVal lpFileName As String) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long

Private Type POINTAPI
        x As Long
        y As Long
End Type

Private Sub Timer1_Timer()
    Dim pntCurrent As POINTAPI
    GetCursorPos pntCurrent
    x = pntCurrent.x * Screen.TwipsPerPixelX
    y = pntCurrent.y * Screen.TwipsPerPixelY
End Sub


This returns the mouse position in twips relative to the screen in its entirety, not the postion in the form. You would have to factor in the position and size of the form and any control contained therein to handle this correctly.
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 6224155
TimCottee: curious why you would need the DeleteFile API hehe
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 6224302
Part of another question, left over from there, good point. HESUS, you can remove that line it is irrelevant here!
0
 

Author Comment

by:HESUS
ID: 6225070
Works perfect.
Thank you very much.
0

Featured Post

Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…
Suggested Courses
Course of the Month3 days, 13 hours left to enroll

630 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