i try to draw rectangle directly on screen with that function:
public static void rectOnScreen2(Rectangle rect, int width = 3, Color? kolor = null)
{
IntPtr desktopPtr = GetDC(IntPtr.Zero);
Pen pen = new Pen(new SolidBrush(kolor ?? Color.Black), width);
Graphics g = Graphics.FromHdc(desktopPtr);
g.DrawRectangle(pen, rect);
g.Dispose();
ReleaseDC(IntPtr.Zero, desktopPtr);
}
but coordinates where it draw my rect is wrong because i have 150% scaling in windows - if i want rect near bootom right corner (eg. new Rectangle(2500,1400,30,30)) it draws it near the middle of screen
when i try rescale rect and when rect is near top left corner of screen - it is ok ;)
but if rect is near bottom right corner it not draw it at all ;(
the same happens when i use g.ScaleTransform(1.5f)
problem is g.VisibleClipBounds - that is: 2560 width and 1440 height on 4k screen
what should i to to get rectangle in right coordinates?