Skip to content

Commit

Permalink
Allow splash screen to move.
Browse files Browse the repository at this point in the history
Signed-off-by: Konstantina Chremmou <Konstantina.Chremmou@cloud.com>
  • Loading branch information
kc284 committed Nov 20, 2023
1 parent a5e14fe commit 25c9704
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
2 changes: 2 additions & 0 deletions XenAdmin/SplashScreen.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions XenAdmin/SplashScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
using System.Drawing;
using System.Windows.Forms;
using XenAdmin.Core;
using XenCenterLib;

namespace XenAdmin
{
Expand Down Expand Up @@ -67,5 +68,24 @@ private void timer1_Tick(object sender, EventArgs e)
timer1.Stop();
ShowMainWindowRequested?.Invoke();
}

private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
SendToForm(e.Button);
}

private void labelCopyright_MouseDown(object sender, MouseEventArgs e)
{
SendToForm(e.Button);
}

private void SendToForm(MouseButtons mouseButton)
{
if (mouseButton == MouseButtons.Left)
{
Win32.ReleaseCapture();
Win32.SendMessage(Handle, Win32.WM_NCLBUTTONDOWN, Win32.HT_CAPTION, 0);
}
}
}
}
12 changes: 10 additions & 2 deletions XenCenterLib/Win32.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ public static int GetGuiResourcesUserCount(IntPtr processHandle)
public const int WM_KEYDOWN = 0x100;

// Mouse Hooks
public const int WM_NCLBUTTONDOWN = 0xA1;
public const int HT_CAPTION = 0x2;
public const int WM_LBUTTONDOWN = 0x201;
public const int WM_LBUTTONDBLCLK = 0x203;
public const int WM_MOUSEWHEEL = 0x20A;
Expand Down Expand Up @@ -186,11 +188,17 @@ public struct POINT
[DllImport("user32.dll")]
public static extern bool DestroyWindow(IntPtr hwnd);

[DllImport("user32.dll")]
public static extern bool ReleaseCapture();

[DllImport("user32.dll")]
public static extern int SendMessage(IntPtr hWnd, int msg, int wParam, int lParam);

[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
public static extern IntPtr SendMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);
public static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);

[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
public static extern IntPtr SendMessage(IntPtr hWnd, int Msg, IntPtr wParam, string lParam);
public static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wParam, string lParam);

[DllImport("user32.dll")]
public static extern IntPtr SetFocus(IntPtr hwnd);
Expand Down

0 comments on commit 25c9704

Please sign in to comment.