private void updateWnd_DoWork(object sender, DoWorkEventArgs e) { while (!gvar.isShuttingDown) { if (_RED_TO_GREEN > 0) { _RED_TO_GREEN--; } else { _RED_TO_GREEN = 765; } Invoke((MethodInvoker) delegate { if (gvar.isShuttingDown) { Close(); } var rect = new Rect(); WinAPI.GetClientRect(Memory.process.MainWindowHandle, out rect); Size = new Size(rect.Right, rect.Bottom); gvar.OverlaySize = Size; var point = new Point(); WinAPI.ClientToScreen(Memory.process.MainWindowHandle, out point); Location = point; gvar.OverlayPoint = Location; isReady = true; }); Thread.Sleep(100); } }
public override Vector2 ConvertToScreen(Vector2 point) { WinAPI.POINT ret = new WinAPI.POINT(); ret.x = point.x; ret.y = point.y; WinAPI.ClientToScreen(WindowHandle, ref ret); return(new Vector2(ret.x, ret.y)); }
private void updateWnd_DoWork(object sender, DoWorkEventArgs e) { while (true) { if (gvar.isShuttingDown) { break; } if (_RED_TO_GREEN > 0) { _RED_TO_GREEN--; } else { _RED_TO_GREEN = 765; } this.Invoke((MethodInvoker) delegate() { if (gvar.isShuttingDown == true) { this.Close(); } if (gvar.OverlaySize != Size) { Rect rect = new Rect(); WinAPI.GetClientRect(Memory.process.MainWindowHandle, out rect); this.Size = new Size(rect.Right, rect.Bottom); int initialStyle = WinAPI.GetWindowLong(this.Handle, -20); WinAPI.SetWindowLong(this.Handle, -20, initialStyle | 0x80000 | 0x20 | 0x80); gvar.OverlaySize = Size; isReady = true; } Point point = new Point(); WinAPI.ClientToScreen(Memory.process.MainWindowHandle, out point); this.Location = point; gvar.OverlayPoint = Location; }); Thread.Sleep(100); } }
private void AdjustForm() { if (!Renderer.Initialized) { return; } Form.Invoke((MethodInvoker) delegate { WinAPI.BringWindowToTop(Form.Handle); WinAPI.RECT rect = new WinAPI.RECT(); WinAPI.POINT pt = new WinAPI.POINT(); if (WinAPI.GetClientRect(Process.Process.MainWindowHandle, out rect) && WinAPI.ClientToScreen(Process.Process.MainWindowHandle, out pt)) { bool sizeChanged = Form.Width != rect.Right - rect.Left || Form.Height != rect.Bottom - rect.Top; bool posChanged = Form.Location.X != pt.X || Form.Location.Y != pt.Y; if (sizeChanged) { Size = new Vector2(rect.Right - rect.Left, rect.Bottom - rect.Top); //BaseContainer.Bounds.Size = Size; } if (posChanged || sizeChanged) { WinAPI.SetWindowPos(Form.Handle, IntPtr.Zero, pt.X, pt.Y, rect.Right - rect.Left, rect.Bottom - rect.Top, 0); } } }); }