public void Highlight() { IntPtr windowDC; RECT windowRect = new RECT(0, 0, 0, 0); NativeUtils.GetWindowRect(detectedWindow, ref windowRect); IntPtr parentWindow = NativeUtils.GetParent(detectedWindow); windowDC = NativeUtils.GetWindowDC(detectedWindow); if (windowDC != IntPtr.Zero) { Graphics graph = Graphics.FromHdc(windowDC, detectedWindow); graph.DrawRectangle(drawPen, 1, 1, windowRect.Width - 2, windowRect.Height - 2); graph.Dispose(); NativeUtils.ReleaseDC(detectedWindow, windowDC); } }
public void Refresh() { if (!IsValid) { return; } IntPtr toUpdate = this.detectedWindow; IntPtr parentWindow = NativeUtils.GetParent(toUpdate); if (parentWindow != IntPtr.Zero) { toUpdate = parentWindow; // using parent } NativeUtils.InvalidateRect(toUpdate, IntPtr.Zero, true); NativeUtils.UpdateWindow(toUpdate); bool result = NativeUtils.RedrawWindow(toUpdate, IntPtr.Zero, IntPtr.Zero, NativeUtils.RDW.RDW_FRAME | NativeUtils.RDW.RDW_INVALIDATE | NativeUtils.RDW.RDW_UPDATENOW | NativeUtils.RDW.RDW_ERASENOW | NativeUtils.RDW.RDW_ALLCHILDREN); }