public static void test01() { //initialize the form var _form = new Form(); Color _color = Color.Black; _form.FormBorderStyle = FormBorderStyle.None; _form.ShowInTaskbar = false; _form.TopMost = true; _form.Visible = false; _form.Left = 0; _form.Top = 0; _form.Width = 1; _form.Height = 1; _form.Hide(); _form.Show(); _form.Opacity = 0.1; //set popup style int num1 = Win32Util.GetWindowLong(_form.Handle, -20); Win32Util.SetWindowLong(_form.Handle, -20, num1 | 0x80); Win32Util.ShowWindow(_form.Handle, 8); Win32Util.SetWindowPos(_form.Handle, Win32Util.HWND_TOPMOST, TLX_, TLY_, width_, height_, 0x10); }
protected override void OnSourceInitialized(EventArgs e) { var hwnd = new WindowInteropHelper(this).Handle; var extendStyle = Win32Util.GetWindowLong(hwnd, -20); var newStyle = extendStyle | 0x00000080 | 0x08000000; Win32Util.SetWindowLong(hwnd, -20, newStyle); Win32Util.SetWindowPos(hwnd, -1, 0, 0, 0, 0, 0x0010 | 0x0002); //TOPMOST SWP_NOACTIVATE NO_MOVE Height = SystemParameters.MaximizedPrimaryScreenHeight - 14; base.OnSourceInitialized(e); }
public void BeginRender() { // Make sure it gets layered! hWnd = w32.handle; var wl = Win32Util.GetWindowLong(hWnd, Win32Util.GWL_EXSTYLE); var ret = Win32Util.SetWindowLong(hWnd, Win32Util.GWL_EXSTYLE, wl | Win32Util.WS_EX_LAYERED); // hook move! noForm.LocationChanged += noForm_LocationChanged; // Start the watcher dobs.Dirty(noForm.DisplayRectangle); dobs.running = true; dobs.StartObserving(); noForm_LocationChanged(noForm.Location); }
public static void test01() { Color transparencyKey = Color.FromArgb(255, 255, 0, 255); f = new Form(); f.Text = "SPM - Surgical Precision Mousing"; f.WindowState = FormWindowState.Maximized; f.ShowInTaskbar = false; f.Visible = false; f.TopMost = true; f.FormBorderStyle = FormBorderStyle.None; f.BackColor = transparencyKey; f.TransparencyKey = transparencyKey; f.Opacity = 1.0; f.AllowTransparency = true; f.Show(); //f.Hide(); //modify extended-window-styles: https://docs.microsoft.com/en-us/windows/desktop/winmsg/extended-window-styles //enable klick trough: https://stackoverflow.com/questions/2798245/click-through-in-c-sharp-form //show without focusing: https://stackoverflow.com/questions/156046/show-a-form-without-stealing-focus/156159#156159 const int WS_EX_LAYERED = 0x80000; const int WS_EX_TRANSPARENT = 0x20; const int SWP_NOACTIVATE = 0x0010; int flags = Win32Util.GetWindowLong(f.Handle, -20); //get the "extended Window Styles" bitmask Win32Util.SetWindowLong(f.Handle, -20, flags | WS_EX_LAYERED | WS_EX_TRANSPARENT); Win32Util.ShowWindow(f.Handle, SWP_NOACTIVATE); //FIXME, does not actually show the form? //https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.control.paint?view=netframework-4.8 //paint event is called when controll is redrawn, i need another event. f.Paint += new PaintEventHandler(FormsTest2.paintCallback); f.MouseMove += new MouseEventHandler(FormsTest2.mouseMoveCallback); f.Update(); }
// https://stackoverflow.com/questions/1536141/how-to-draw-directly-on-the-windows-desktop-c/37707278#37707278 public static void makeKlicktrough(this Form @this) { Win32Util.SetWindowLong(@this.Handle, Win32Util.GWL_EXSTYLE, Win32Util.GetWindowLong(@this.Handle, Win32Util.GWL_EXSTYLE) | Win32Util.WS_EX_LAYERED | Win32Util.WS_EX_TRANSPARENT); }