Is it possible to draw a point on the monitor screen (in any or a specific part of it), not on the form !?

    1 answer 1

    Yes, it is, of course, possible. Any graphic output device has its own context, a device context handle, and any Windows window can act as a device. Since the desktop is the same ordinary Windows window (which is always the first to be cracked, therefore it has the device context ID = 0), you can perform any operations with it that can only be performed on windows. For example, you can draw in this window (more precisely in its context). You just have to create a new object of the Bitmap class, assign its context context to the context identifier and draw the same BitMap`e in the same way, while all, as you already hope, understand, will be displayed on the desktop window. In Delphi, for example, assigning a desktop context identifier looks like this:

    bitmap.canvas.handle := GetDC(0); 

    Yes, I almost forgot that GetDC () is the WinApi function for getting the device context (HDC) of the window output by its handle (HWND), so do not forget to import this function from the library. Like so:

     [DllImport("coredll.dll", EntryPoint = "GetDC")] public static extern IntPtr GetDC(IntPtr hWnd); 
    • This will be a point on the desktop, and not “on the monitor” :) If at the same time the window is blocked by the drawing, the point will not be visible. I'm afraid it is impossible to draw a dot exactly "on the monitor". For drawing in Windows, in any case, you need the Device Context that the windows own. - Shad
    • Well, you can put any transparent form on the whole screen and draw on it, it is not essential. - Smash