Fix shiftnet crash with custom cursors
This commit is contained in:
parent
9a9ec274d3
commit
9a37e472fb
2 changed files with 27 additions and 10 deletions
|
@ -135,19 +135,25 @@ namespace ShiftOS.WinForms.Tools
|
|||
}
|
||||
}
|
||||
|
||||
public static void SetCursor(Control ctrl)
|
||||
{
|
||||
if (!(ctrl is WebBrowser))
|
||||
{
|
||||
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();
|
||||
|
||||
ctrl.Cursor = new Cursor(handle);
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetupControl(Control ctrl)
|
||||
{
|
||||
|
||||
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();
|
||||
|
||||
ctrl.Cursor = new Cursor(handle);
|
||||
SetCursor(ctrl);
|
||||
if (!(ctrl is MenuStrip) && !(ctrl is ToolStrip) && !(ctrl is StatusStrip) && !(ctrl is ContextMenuStrip))
|
||||
{
|
||||
string tag = "";
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue