aboutsummaryrefslogtreecommitdiff
path: root/TimeHACK.Main/TitleScreen.cs
diff options
context:
space:
mode:
authorAlex-TIMEHACK <[email protected]>2017-06-24 21:42:18 +0100
committerGitHub <[email protected]>2017-06-24 21:42:18 +0100
commit35abc60de28f0d03c98775a34ecded0a41b7e31b (patch)
tree73af656fdc8de557cb9bc8ee50321ea7486d8204 /TimeHACK.Main/TitleScreen.cs
parent1027a2cff07c579a013519aebebd948e23e6f2ce (diff)
parent7da34021e20e8e9cabc2ab9e74ca44f34db120d2 (diff)
downloadhistacom2-35abc60de28f0d03c98775a34ecded0a41b7e31b.tar.gz
histacom2-35abc60de28f0d03c98775a34ecded0a41b7e31b.tar.bz2
histacom2-35abc60de28f0d03c98775a34ecded0a41b7e31b.zip
Merge pull request #100 from Alex-TIMEHACK/master
Made the TitleScreen use the WindowManager
Diffstat (limited to 'TimeHACK.Main/TitleScreen.cs')
-rw-r--r--TimeHACK.Main/TitleScreen.cs64
1 files changed, 64 insertions, 0 deletions
diff --git a/TimeHACK.Main/TitleScreen.cs b/TimeHACK.Main/TitleScreen.cs
index 0d7ee36..977f1e5 100644
--- a/TimeHACK.Main/TitleScreen.cs
+++ b/TimeHACK.Main/TitleScreen.cs
@@ -8,12 +8,18 @@ using TimeHACK.OS.Win98;
using TimeHACK.Engine;
using static TimeHACK.Engine.SaveSystem;
using TimeHACK.SaveDialogs;
+using System.Runtime.InteropServices;
+using System.Reflection;
+using System.ComponentModel;
namespace TimeHACK
{
public partial class TitleScreen : Form
{
public static System.Drawing.Text.PrivateFontCollection pfc = new System.Drawing.Text.PrivateFontCollection();
+
+ TimeHACK.Engine.Template.WinClassic borders = new TimeHACK.Engine.Template.WinClassic();
+
public static Windows95 frm95;
public static Windows98 frm98;
public static string username;
@@ -25,6 +31,19 @@ namespace TimeHACK
public static NewGameDialog newGameBox;
public static LoadGameDialog loadGameBox;
+ // Border stuff
+
+ public Boolean max = false;
+
+ public const int WM_NCLBUTTONDOWN = 0xA1;
+ public const int HT_CAPTION = 0x2;
+
+ [DllImportAttribute("user32.dll")]
+ public static extern int SendMessage(IntPtr hWnd,
+ int Msg, int wParam, int lParam);
+ [DllImportAttribute("user32.dll")]
+ public static extern bool ReleaseCapture();
+
public void StartGame()
{
//TODO: You may want to handle story stuff to decide what OS to boot here.
@@ -82,6 +101,51 @@ namespace TimeHACK
public TitleScreen()
{
InitializeComponent();
+
+ // Add the WINDOWS BORDERS from the Window Manager
+
+ FieldInfo f1 = typeof(Control).GetField("EventMouseDown",
+ BindingFlags.Static | BindingFlags.NonPublic);
+ object obj = f1.GetValue(borders.programtopbar);
+ PropertyInfo pi = borders.programtopbar.GetType().GetProperty("Events",
+ BindingFlags.NonPublic | BindingFlags.Instance);
+ EventHandlerList list = (EventHandlerList)pi.GetValue(borders.programtopbar, null);
+ list.RemoveHandler(obj, list[obj]);
+
+ borders.programtopbar.MouseDown += new MouseEventHandler(TitleBarDrag);
+ borders.programtopbar.Controls.Find("closebutton", false)[0].MouseClick += new MouseEventHandler(closeButton);
+ borders.programtopbar.Controls.Find("maximizebutton", false)[0].MouseClick += new MouseEventHandler(MaximiseButton);
+
+ this.Controls.Add(borders.programtopbar);
+ this.Controls.Add(borders.right);
+ this.Controls.Add(borders.left);
+ this.Controls.Add(borders.bottom);
+
+
+ }
+
+ void TitleBarDrag(object sender, MouseEventArgs e)
+ {
+ if (e.Button == MouseButtons.Left && max == false)
+ {
+ ReleaseCapture();
+ SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
+ }
+ }
+
+ void MaximiseButton(object sender, MouseEventArgs e)
+ {
+ if (this.WindowState == FormWindowState.Normal)
+ {
+ this.WindowState = FormWindowState.Maximized;
+ } else {
+ this.WindowState = FormWindowState.Normal;
+ }
+ }
+
+ void closeButton(object sender, MouseEventArgs e)
+ {
+ Close();
}
private void closebutton_Click(object sender, EventArgs e)