0

I was having a lot of trouble with aligning where a pop-up menu should appear, when I grew really frustrated with not being able to pin down several pixels of an offset.

So I made a simple program that showed me just the current cursor position, and form window position, and I found that for some reason, the Form.Left coordinate is offset by 7? When I move the window to the very top left corner, the coordinates show -7,0, and when I move the window to 0,0 the window is offset by a few pixels to the right. See screenshots.

Can anyone explain this to me? Why is this happening, and if there's a way to fix it? Also, why is it not affecting the vertical position?

enter image description here

enter image description here

Neamow
  • 23
  • 3
  • Where does the form end up when you call `Left := 0; Top := 0;`? – Sertac Akyuz Apr 06 '20 at 16:06
  • First screenshot. With a few pixels of room to the left. – Neamow Apr 06 '20 at 16:45
  • 1
    After you set to 0,0 by code verify the position by a 3rd party application, like WinSpy++. If the window is off then you likely have a DPI virtualization problem. – Sertac Akyuz Apr 06 '20 at 17:18
  • 2
    [An answer](https://stackoverflow.com/a/42491227/2292722) to a similar question sheds some light on the reasons and a possible workaround. Search for more examples with `window position Windows 10` – Tom Brunberg Apr 06 '20 at 20:11
  • Ah that does look like the exact same issue. I tried searching for it but I guess I was using wrong keywords. Thanks! – Neamow Apr 06 '20 at 21:53

0 Answers0