Make splash screen draggable

This commit is contained in:
Damien Guard
2018-01-04 12:42:01 -08:00
parent 70a3f61027
commit 9f5382ee82

View File

@@ -5,6 +5,7 @@ using System.Drawing;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
@@ -14,6 +15,14 @@ namespace Squirrel.Update
{
public class AnimatedGifWindow : Form
{
const int WM_NCLBUTTONDOWN = 0xA1;
const int HT_CAPTION = 0x2;
[DllImport("user32.dll")]
static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
[DllImport("user32.dll")]
static extern bool ReleaseCapture();
PictureBox pictureBox;
AnimatedGifWindow()
@@ -47,6 +56,14 @@ namespace Squirrel.Update
this.CenterToScreen();
};
// Enable left-mouse button to drag window
pictureBox.MouseDown += (o, e) => {
if (e.Button == MouseButtons.Left) {
ReleaseCapture();
SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
}
};
this.FormBorderStyle = FormBorderStyle.None;
this.Width = 1;
this.Height = 1;