Hello,
I am writing some declares for working with multiple monitors and am running into an issue when retrieving the handle of a monitor based on a global mouse position. If the mouse is in another screen then it will display the monitor handle (hdlMonitor) where the mouse is located. The program works great in x86. When running in Xojo 2017 r2.1, the monitor handle only appears when the mouse y-value is seperated by values of 32.
Example: The windows handle will appear in x64 mode with the following y-mouse values:
0, 1, 2,
32, 33, 34,
64, 65, 66,
96, 97, 98,
multiples of 32 — etc…
If the y-mouse value is between 3-31, or 35-63, etc, then the handle is not shown. It works perfectly in x86 though.
Here is the code which is in the Timer1 Action event (needed for global mouse values):
[code]Sub Action() Handles Action
//Create a MyPoint variable from the POINTAPI Structure
Dim MyPoint as POINTAPI
//Get the current global mouse position
MyPoint.X = System.MouseX
MyPoint.Y = System.MouseY
//Show the position in the TextArea1 Control
TextArea1.Text = "Global Mouse Coordinates: X: " + MyPoint.X.ToText + ", Y: " + System.MouseY.Totext + EndOfLine
Const MONITOR_DEFAULTTONULL = &H0
Const MONITOR_DEFAULTTOPRIMARY = &H1
Const MONITOR_DEFAULTTONEAREST = &H2
//Return the handle to the monitor nearest the current cursor position
Dim hdlMonitor as Integer = MonitorFromPoint(MyPoint, MONITOR_DEFAULTTONEAREST)
TextArea1.Text = TextArea1.Text + "Monitor Handle: " + hdlMonitor.ToText + EndOfLine
End Sub
[/code]
Here is an example project download link: Example20-02e.zip
There is likely something simple that I am missing, and the code is quite simple… Any helpful thoughts on what it could be?
Thanks!
Edit: changed y-mouse value from 35-64 to 35-63.