Getting mouse position


L

Lorne

I want to create a popup window that shows so the bottom right of the popup
is on the mouse cursor when the mouse clicks an object with the relevant
macro enabled. My code below works, but I do not understand why I have to
multiply the results of GetCursorPos() by 0.75 to get the right result. It
seems PowerPoint uses a different pixel resolution to what my computers are
set to (the code below works OK on two desktops and a laptop).

Can somebody tell me why the 0.75 multiplication is needed. Also, is my
code robust for use on any computer with any screen resolution or is there
something to be careful of. (please give some code example if I do need to
be careful.

Thanks if you can help.

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

Private Type POINTAPI
x As Long
y As Long
End Type

Dim ret As Long
Dim Mpos As POINTAPI

Sub fmCashSurplusShow()
ret = GetCursorPos(Mpos)
fmCashSurplus.Left = Mpos.x * 3 / 4 - fmCashSurplus.Width
fmCashSurplus.Top = Mpos.y * 3 / 4 - fmCashSurplus.Height
fmCashSurplus.Show
End Sub
 
Ad

Advertisements

Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top