Currently i'm only using the User32.dll functions
WindowFromPoint(Point) WindowFromPoint(Int, Int) GetWindowText(IntPtr, StringBuilder, Int) GetWindowTextLength(IntPtr) GetWindowRect(HandleRef, RECT) 'RECT is a custom structure consisting of 4 integers GetDesktopWindow() 'IntPtr of the desktop, using as a test for drawing.
What i'm doing with this is eventually I'm going to do what programs like SnagIt do, draw a box around the window under the mouse, and on click take the screenshot.
I've got the screenshot method down, I'm able to find the window under the mouse, but I am unable to efficiently draw on the screen.
I've been thinking of different ways to do this but the only one worth mentioning won't work.
Take a screenshot of the entire screen, display in form, wait for user to select crop area.
This would work if I wasn't trying to take an image of the specific window. I would need to implement border detection in GDI functions and i'm just not that smart haha, I don't even know where to begin with that one.
All GDI drawing over the desktop hWnd is unresponsive and glitchy, simply moving my mouse over a control that activates anywhere will clear the entire window's paint.
The last method I used:
Dim brush As New Drawing2D.HatchBrush(Drawing2D.HatchStyle.DashedDownwardDiagonal, Color.Red, Color.Black) Dim screenRect As Rectangle = GetRect(GetDesktopWindow) Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs) MyBase.OnPaint(e) Using g As Graphics = Graphics.FromHwnd(GetDesktopWindow) g.FillRectangle(brush, screenRect) End Using End Sub
It's also a tad slow?
I guess my question is, is there a way to draw on the screen without it being glitchy? There as to be, there are programs out there that do it.
While typing this out, I realized developers must have found a way to lock current screen updates and are drawing using gdi over the locked screen; no updates means no activated controls, but i still don't see how they are getting windows from locked controls with GetWindowRect/GetWindowAtPoint etc. BUT, No updates also means no GDI rendering? I shall look into this a little more, but if there are more constructive answers I certainly need the help!