enable click-through
This commit is contained in:
parent
adff5ee3ac
commit
5f2a207474
2 changed files with 39 additions and 6 deletions
|
@ -61,9 +61,6 @@ namespace DutyContent.Overlay
|
|||
|
||||
private void DoMoveDown(MouseEventArgs e)
|
||||
{
|
||||
if (DcConfig.Duty.OverlayClickThru)
|
||||
return;
|
||||
|
||||
if (e.Button == MouseButtons.Left)
|
||||
{
|
||||
ThirdParty.NativeMethods.ReleaseCapture();
|
||||
|
@ -73,9 +70,6 @@ namespace DutyContent.Overlay
|
|||
|
||||
protected override void OnMouseDown(MouseEventArgs e)
|
||||
{
|
||||
if (DcConfig.Duty.OverlayClickThru)
|
||||
return;
|
||||
|
||||
base.OnMouseDown(e);
|
||||
DoMoveDown(e);
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ using System.Net;
|
|||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace DutyContent.Tab
|
||||
{
|
||||
|
@ -34,6 +35,12 @@ namespace DutyContent.Tab
|
|||
_overlay = new Overlay.DutyOvForm();
|
||||
}
|
||||
|
||||
// Used for click-through function
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
static extern int GetWindowLong(IntPtr hWnd, int nIndex);
|
||||
[DllImport("user32.dll")]
|
||||
static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
|
||||
|
||||
private void DutyTabForm_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
|
||||
|
@ -75,6 +82,8 @@ namespace DutyContent.Tab
|
|||
_overlay.Show();
|
||||
else
|
||||
_overlay.Hide();
|
||||
if (DcConfig.Duty.OverlayClickThru)
|
||||
enableOverlayClickThru();
|
||||
|
||||
//
|
||||
chkEnableSound.Checked = DcConfig.Duty.EnableSound;
|
||||
|
@ -669,6 +678,10 @@ namespace DutyContent.Tab
|
|||
return;
|
||||
|
||||
DcConfig.Duty.OverlayClickThru = chkOverlayClickThru.Checked;
|
||||
if (DcConfig.Duty.OverlayClickThru)
|
||||
enableOverlayClickThru();
|
||||
else
|
||||
disableOverlayClickThru();
|
||||
|
||||
SaveConfig();
|
||||
}
|
||||
|
@ -1314,5 +1327,31 @@ namespace DutyContent.Tab
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
void enableOverlayClickThru()
|
||||
{
|
||||
int initialStyle = GetWindowLong(_overlay.Handle, -20);
|
||||
if (DcConfig.Duty.OverlayClickThru)
|
||||
{
|
||||
SetWindowLong(_overlay.Handle, -20, initialStyle | 0x80000 | 0x20);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetWindowLong(_overlay.Handle, -20, (0x00000 | 0x80000));
|
||||
}
|
||||
}
|
||||
|
||||
void disableOverlayClickThru()
|
||||
{
|
||||
int initialStyle = GetWindowLong(_overlay.Handle, -20);
|
||||
if (DcConfig.Duty.OverlayClickThru)
|
||||
{
|
||||
SetWindowLong(_overlay.Handle, -20, initialStyle | 0x80000 | 0x20);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetWindowLong(_overlay.Handle, -20, (0x00000 | 0x80000));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue