Solved

Mouse Possition

Posted on 2001-06-25
4
123 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

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!

Question has a verified solution.

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

Suggested Solutions

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
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…

752 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