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); }
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(); }