I am using the following code to place a rectangle around a form / form control, however what I want to do is make my screen grey and only the form / form control area be displayed in colour.
I have googled for ages trying to find something on this, but with no luck.
To illistrate this better they are using the same functionality in snagit 10, please see below link to a page that has a video link showing this (23 sec into video)
TechSmith | Snagit, screen capture software, features
Thanks
Simon
VB.NET:
Imports System.Diagnostics
Imports System.Drawing
Imports System.Windows.Forms
Namespace CodeReflection.ScreenCapturingDemo
''' <summary>
''' Summary description for WindowHighlighter.
''' </summary>
Public Class WindowHighlighter
''' <summary>
''' Highlights the specified window just like Spy++
''' </summary>
''' <param name="hWnd"></param>
Public Shared Sub Highlight(hWnd As IntPtr)
Const penWidth As Single = 3
Dim rc As New Win32.Rect()
Win32.GetWindowRect(hWnd, rc)
Dim hDC As IntPtr = Win32.GetWindowDC(hWnd)
If hDC <> IntPtr.Zero Then
Using pen As New Pen(Color.Black, penWidth)
Using g As Graphics = Graphics.FromHdc(hDC)
g.DrawRectangle(pen, 0, 0, rc.right - rc.left - CInt(Math.Truncate(penWidth)), rc.bottom - rc.top - CInt(Math.Truncate(penWidth)))
End Using
End Using
End If
Win32.ReleaseDC(hWnd, hDC)
End Sub
''' <summary>
''' Forces a window to refresh, to eliminate our funky highlighted border
''' </summary>
''' <param name="hWnd"></param>
Public Shared Sub Refresh(hWnd As IntPtr)
' TRUE
Win32.InvalidateRect(hWnd, IntPtr.Zero, 1)
Win32.UpdateWindow(hWnd)
Win32.RedrawWindow(hWnd, IntPtr.Zero, IntPtr.Zero, Win32.RDW_FRAME Or Win32.RDW_INVALIDATE Or Win32.RDW_UPDATENOW Or Win32.RDW_ALLCHILDREN)
End Sub
End Class
End Namespace
I have googled for ages trying to find something on this, but with no luck.
To illistrate this better they are using the same functionality in snagit 10, please see below link to a page that has a video link showing this (23 sec into video)
TechSmith | Snagit, screen capture software, features
Thanks
Simon