public OverlayHost() { this.AutoScaleMode = AutoScaleMode.None; ui = this; this.TopMost = true; Console.WriteLine("Starting Tab GUI..."); this.FormBorderStyle = FormBorderStyle.None; this.TransparencyKey = Color.FromArgb(77, 77, 77); this.BackColor = this.TransparencyKey; this.Location = new Point(0, 0); this.DoubleBuffered = true; this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true); //DBG.Debug("Set overlay styles"); hWnd = this.Handle; overDel = new WinEventDelegate(adjustOverlay); //DBG.Debug("Registered event delegates"); SetWinEventHook((uint)SWEH_Events.EVENT_OBJECT_LOCATIONCHANGE, (uint)SWEH_Events.EVENT_OBJECT_LOCATIONCHANGE, IntPtr.Zero, overDel, (uint)MCM.mcWinProcId, GetWindowThreadProcessId(MCM.mcWinHandle, IntPtr.Zero), (uint)SWEH_dwFlags.WINEVENT_OUTOFCONTEXT | (uint)SWEH_dwFlags.WINEVENT_SKIPOWNPROCESS | (uint)SWEH_dwFlags.WINEVENT_SKIPOWNTHREAD); SetWinEventHook((uint)SWEH_Events.EVENT_SYSTEM_FOREGROUND, (uint)SWEH_Events.EVENT_SYSTEM_FOREGROUND, IntPtr.Zero, overDel, 0, 0, (uint)SWEH_dwFlags.WINEVENT_OUTOFCONTEXT | (uint)SWEH_dwFlags.WINEVENT_SKIPOWNPROCESS | (uint)SWEH_dwFlags.WINEVENT_SKIPOWNTHREAD); //DBG.Debug("Hooked win events"); //mouseHookID= SetWindowsHookEx(14, mouseMove, GetModuleHandle("user32"), 0); UInt64 initialStyle = GetWindowLong(this.Handle, -20); SetWindowLong(this.Handle, -20, initialStyle | 0x80000 | 0x20); //DBG.Debug("Set overlay window styles (2)"); if (postOverlayLoad != null) { postOverlayLoad.Invoke(this, new EventArgs()); //DBG.Debug("Invoked post overlay event"); } Paint += OverlayHost_Paint; //DBG.Debug("paint hooked"); }
public OverlayHost() { this.AutoScaleMode = AutoScaleMode.None; ui = this; this.TopMost = true; Console.WriteLine("Starting TabGUI."); this.FormBorderStyle = FormBorderStyle.None; this.TransparencyKey = Color.FromArgb(77, 77, 77); this.BackColor = this.TransparencyKey; this.Location = new Point(0, 0); this.DoubleBuffered = true; this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true); hWnd = this.Handle; overDel = new WinEventDelegate(adjustOverlay); mouseMove = new LowLevelMouseProc(OnMouseMove); SetWinEventHook((uint)SWEH_Events.EVENT_OBJECT_LOCATIONCHANGE, (uint)SWEH_Events.EVENT_OBJECT_LOCATIONCHANGE, IntPtr.Zero, overDel, (uint)MCM.mcWinProcId, GetWindowThreadProcessId(MCM.mcWinHandle, IntPtr.Zero), (uint)SWEH_dwFlags.WINEVENT_OUTOFCONTEXT | (uint)SWEH_dwFlags.WINEVENT_SKIPOWNPROCESS | (uint)SWEH_dwFlags.WINEVENT_SKIPOWNTHREAD); SetWinEventHook((uint)SWEH_Events.EVENT_SYSTEM_FOREGROUND, (uint)SWEH_Events.EVENT_SYSTEM_FOREGROUND, IntPtr.Zero, overDel, 0, 0, (uint)SWEH_dwFlags.WINEVENT_OUTOFCONTEXT | (uint)SWEH_dwFlags.WINEVENT_SKIPOWNPROCESS | (uint)SWEH_dwFlags.WINEVENT_SKIPOWNTHREAD); //mouseHookID= SetWindowsHookEx(14, mouseMove, GetModuleHandle("user32"), 0); UInt64 initialStyle = GetWindowLong(this.Handle, -20); SetWindowLong(this.Handle, -20, initialStyle | 0x80000 | 0x20); Timer rainbowTimer = new Timer(); float rainbowTick = 0f; rainbowTimer.Tick += (object segfsjn, EventArgs gfdd) => { if (MCM.isMinecraftFocused()) { rainbowTick += 0.005f; rainbow = new SolidBrush(Rainbow(rainbowTick)); this.Invalidate(); } }; rainbowTimer.Interval = 10; rainbowTimer.Stop(); if (postOverlayLoad != null) { postOverlayLoad.Invoke(this, new EventArgs()); } Paint += OverlayHost_Paint; }