Simplify ToolStripEx
This commit is contained in:
parent
68797f18f7
commit
0def3828b9
|
@ -8,30 +8,18 @@ using System.Windows.Forms;
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ToolStripEx : ToolStrip
|
public class ToolStripEx : ToolStrip
|
||||||
{
|
{
|
||||||
private bool clickThrough = true;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets whether the ToolStripEx honors item clicks when its containing form does
|
/// Gets or sets whether the ToolStripEx honors item clicks when its containing form does
|
||||||
/// not have input focus.
|
/// not have input focus.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool ClickThrough
|
public bool ClickThrough { get; set; } = true;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return clickThrough;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
clickThrough = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void WndProc(ref Message m)
|
protected override void WndProc(ref Message m)
|
||||||
{
|
{
|
||||||
base.WndProc(ref m);
|
base.WndProc(ref m);
|
||||||
if (clickThrough &&
|
if (ClickThrough
|
||||||
m.Msg == NativeConstants.WM_MOUSEACTIVATE &&
|
&& m.Msg == NativeConstants.WM_MOUSEACTIVATE
|
||||||
m.Result == (IntPtr)NativeConstants.MA_ACTIVATEANDEAT)
|
&& m.Result == (IntPtr)NativeConstants.MA_ACTIVATEANDEAT)
|
||||||
{
|
{
|
||||||
m.Result = (IntPtr)NativeConstants.MA_ACTIVATE;
|
m.Result = (IntPtr)NativeConstants.MA_ACTIVATE;
|
||||||
}
|
}
|
||||||
|
@ -43,30 +31,18 @@ public class ToolStripEx : ToolStrip
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class MenuStripEx : MenuStrip
|
public class MenuStripEx : MenuStrip
|
||||||
{
|
{
|
||||||
private bool clickThrough = true;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets whether the ToolStripEx honors item clicks when its containing form does
|
/// Gets or sets whether the ToolStripEx honors item clicks when its containing form does
|
||||||
/// not have input focus.
|
/// not have input focus.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool ClickThrough
|
public bool ClickThrough { get; set; } = true;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return clickThrough;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
clickThrough = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void WndProc(ref Message m)
|
protected override void WndProc(ref Message m)
|
||||||
{
|
{
|
||||||
base.WndProc(ref m);
|
base.WndProc(ref m);
|
||||||
if (clickThrough &&
|
if (ClickThrough
|
||||||
m.Msg == NativeConstants.WM_MOUSEACTIVATE &&
|
&& m.Msg == NativeConstants.WM_MOUSEACTIVATE
|
||||||
m.Result == (IntPtr)NativeConstants.MA_ACTIVATEANDEAT)
|
&& m.Result == (IntPtr)NativeConstants.MA_ACTIVATEANDEAT)
|
||||||
{
|
{
|
||||||
m.Result = (IntPtr)NativeConstants.MA_ACTIVATE;
|
m.Result = (IntPtr)NativeConstants.MA_ACTIVATE;
|
||||||
}
|
}
|
||||||
|
@ -78,30 +54,18 @@ public class MenuStripEx : MenuStrip
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class StatusStripEx : StatusStrip
|
public class StatusStripEx : StatusStrip
|
||||||
{
|
{
|
||||||
private bool clickThrough = true;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets whether the ToolStripEx honors item clicks when its containing form does
|
/// Gets or sets whether the ToolStripEx honors item clicks when its containing form does
|
||||||
/// not have input focus.
|
/// not have input focus.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool ClickThrough
|
public bool ClickThrough { get; set; } = true;
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return clickThrough;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
clickThrough = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void WndProc(ref Message m)
|
protected override void WndProc(ref Message m)
|
||||||
{
|
{
|
||||||
base.WndProc(ref m);
|
base.WndProc(ref m);
|
||||||
if (clickThrough &&
|
if (ClickThrough
|
||||||
m.Msg == NativeConstants.WM_MOUSEACTIVATE &&
|
&& m.Msg == NativeConstants.WM_MOUSEACTIVATE
|
||||||
m.Result == (IntPtr)NativeConstants.MA_ACTIVATEANDEAT)
|
&& m.Result == (IntPtr)NativeConstants.MA_ACTIVATEANDEAT)
|
||||||
{
|
{
|
||||||
m.Result = (IntPtr)NativeConstants.MA_ACTIVATE;
|
m.Result = (IntPtr)NativeConstants.MA_ACTIVATE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue