diff options
| author | Michael <[email protected]> | 2017-02-04 14:19:45 -0500 |
|---|---|---|
| committer | Michael <[email protected]> | 2017-02-04 14:19:45 -0500 |
| commit | 9a37e472fb4e85a1838e06c03eb1632557a6f13c (patch) | |
| tree | 13b1562e1c4cad9e6af389d7b554865c5f16d289 /ShiftOS.WinForms | |
| parent | 9a9ec274d32b78291c9ca489a0cc7ce45e85907e (diff) | |
| download | shiftos_thereturn-9a37e472fb4e85a1838e06c03eb1632557a6f13c.tar.gz shiftos_thereturn-9a37e472fb4e85a1838e06c03eb1632557a6f13c.tar.bz2 shiftos_thereturn-9a37e472fb4e85a1838e06c03eb1632557a6f13c.zip | |
Fix shiftnet crash with custom cursors
Diffstat (limited to 'ShiftOS.WinForms')
| -rw-r--r-- | ShiftOS.WinForms/Tools/ControlManager.cs | 24 | ||||
| -rw-r--r-- | ShiftOS.WinForms/WinformsDesktop.cs | 11 |
2 files changed, 26 insertions, 9 deletions
diff --git a/ShiftOS.WinForms/Tools/ControlManager.cs b/ShiftOS.WinForms/Tools/ControlManager.cs index 8eba773..1067c3f 100644 --- a/ShiftOS.WinForms/Tools/ControlManager.cs +++ b/ShiftOS.WinForms/Tools/ControlManager.cs @@ -135,19 +135,25 @@ namespace ShiftOS.WinForms.Tools } } - - public static void SetupControl(Control ctrl) + public static void SetCursor(Control ctrl) { + if (!(ctrl is WebBrowser)) + { + var mouse = SkinEngine.GetImage("mouse"); + if (mouse == null) + mouse = Properties.Resources.DefaultMouse; - var mouse = SkinEngine.GetImage("mouse"); - if (mouse == null) - mouse = Properties.Resources.DefaultMouse; + var mBmp = new Bitmap(mouse); + var gfx = Graphics.FromImage(mBmp); + var handle = mBmp.GetHicon(); - var mBmp = new Bitmap(mouse); - var gfx = Graphics.FromImage(mBmp); - var handle = mBmp.GetHicon(); + ctrl.Cursor = new Cursor(handle); + } + } - ctrl.Cursor = new Cursor(handle); + public static void SetupControl(Control ctrl) + { + SetCursor(ctrl); if (!(ctrl is MenuStrip) && !(ctrl is ToolStrip) && !(ctrl is StatusStrip) && !(ctrl is ContextMenuStrip)) { string tag = ""; diff --git a/ShiftOS.WinForms/WinformsDesktop.cs b/ShiftOS.WinForms/WinformsDesktop.cs index c45feee..7f8f232 100644 --- a/ShiftOS.WinForms/WinformsDesktop.cs +++ b/ShiftOS.WinForms/WinformsDesktop.cs @@ -109,6 +109,16 @@ namespace ShiftOS.WinForms time.Start(); this.DoubleBuffered = true; + SetCursors(this); + } + + public void SetCursors(Control ctrl) + { + ControlManager.SetupControl(ctrl); + foreach(Control child in ctrl.Controls) + { + SetCursors(child); + } } /// <summary> @@ -178,6 +188,7 @@ namespace ShiftOS.WinForms pnlbtn.Click += onClick; pnlbtntext.Click += onClick; } + SetCursors(pnlbtn); } } } |
