Stuart McLachlan
stuart at lexacorp.com.pg
Fri Sep 19 08:55:12 CDT 2003
On 19 Sep 2003 at 14:58, Erwin Craps wrote: > I can't find how to know the postition of the mouse on the screen. > > I have a pop-up form I want to pop-up at the same place as where the > mouse cursor is at that time. > So I want to put put the code in the on_open event of the pop-up form in > question > > lngMouseLeft = ???.Left > lngMouseTop = ???.Top > > me.move lngMouseLeft, lngMouseTop > It gets quite tricky. You can find the current mouse position in pixels easily enough: In a module: Type POINTAPI x As Long y As Long End Type Declare Function GetCursorPos Lib "USER32.DLL" (lpPoint As POINTAPI) As Long In your event: Dim mptr As POINTAPI Dim result As Long result = GetCursorPos(mptr) Msgbox "Mouse is at Screen position " & mptr.x & " : " & mptr.y & " in pixels" However, that doesn't really help. Forms are positioned in twips relative to their parent (usually the main application window). You need to get a handle to the parent window using the GetActiveWindow() and GetWindow() API calls then get the location of that window using GetWindowPlacement. Then you need to convert these pixel figures to twips and use Docmd.MoveSize to place the from at an appropriate position within it's parent. -- Lexacorp Ltd http://www.lexacorp.com.pg Information Technology Consultancy, Software Development,System Support.