Solved

Mouse Possition

Posted on 2001-06-25
4
118 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
  • 2
4 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 100 total points
Comment Utility
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 142

Expert Comment

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

Expert Comment

by:TimCottee
Comment Utility
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
Comment Utility
Works perfect.
Thank you very much.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

728 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now