Note that there are some explanatory texts on larger screens.

plurals
  1. PODrawing over all windows on multiple monitors
    primarykey
    data
    text
    <p>I am using the following code to draw on a single monitor:</p> <pre><code>Point cursorLocation; NativeMethods.GetCursorPos(out cursorLocation); Screen screen = Screen.FromPoint(cursorLocation); Point h1 = new Point(screen.Bounds.Left, cursorLocation.Y); Point h2 = new Point(screen.Bounds.Right, cursorLocation.Y); Point v1 = new Point(cursorLocation.X, screen.Bounds.Top); Point v2 = new Point(cursorLocation.X, screen.Bounds.Bottom); using (Graphics graphics = Graphics.FromHwnd(NativeMethods.GetDesktopWindow())) { NativeMethods.SHChangeNotify(0x8000000, 0x1000, IntPtr.Zero, IntPtr.Zero); graphics.DrawLine(Pens.Red, h1, h2); graphics.DrawLine(Pens.Red, v1, v2); } </code></pre> <p>Natively, this <em>should</em> <em>theoretically</em> draw on either monitor. However, it only draws on the primary. So, to fix this I am getting the DC of all the displays and trying to do it this way.</p> <pre><code>IntPtr hdc = NativeMethods.CreateDC("DISPLAY", IntPtr.Zero, IntPtr.Zero, IntPtr.Zero); Graphics graphics = Graphics.FromHdc(hdc); graphics.DrawLine(Pens.Red, h1, h2); graphics.DrawLine(Pens.Red, v1, v2); graphics.Dispose(); NativeMethods.ReleaseDC(IntPtr.Zero, hdc); </code></pre> <p>Go figure, this doesn't even draw to the screen at all. I have tried various overloads for CreateDC, as well as searched SO and other resources and I'm stumped. </p> <hr> <p>Once this is resolved, anyone know how to get rid of flicker by refreshing the desktop using SHCHangeNotify? I'm only drawing two lines and it flickers like mad..)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload