enable click-through

This commit is contained in:
Jaehyuk-Lee 2021-06-06 05:58:56 +09:00
parent adff5ee3ac
commit 5f2a207474
2 changed files with 39 additions and 6 deletions

View file

@ -61,9 +61,6 @@ namespace DutyContent.Overlay
private void DoMoveDown(MouseEventArgs e) private void DoMoveDown(MouseEventArgs e)
{ {
if (DcConfig.Duty.OverlayClickThru)
return;
if (e.Button == MouseButtons.Left) if (e.Button == MouseButtons.Left)
{ {
ThirdParty.NativeMethods.ReleaseCapture(); ThirdParty.NativeMethods.ReleaseCapture();
@ -73,9 +70,6 @@ namespace DutyContent.Overlay
protected override void OnMouseDown(MouseEventArgs e) protected override void OnMouseDown(MouseEventArgs e)
{ {
if (DcConfig.Duty.OverlayClickThru)
return;
base.OnMouseDown(e); base.OnMouseDown(e);
DoMoveDown(e); DoMoveDown(e);
} }

View file

@ -9,6 +9,7 @@ using System.Net;
using System.Net.Http; using System.Net.Http;
using System.Text; using System.Text;
using System.IO; using System.IO;
using System.Runtime.InteropServices;
namespace DutyContent.Tab namespace DutyContent.Tab
{ {
@ -34,6 +35,12 @@ namespace DutyContent.Tab
_overlay = new Overlay.DutyOvForm(); _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) private void DutyTabForm_FormClosing(object sender, FormClosingEventArgs e)
{ {
@ -75,6 +82,8 @@ namespace DutyContent.Tab
_overlay.Show(); _overlay.Show();
else else
_overlay.Hide(); _overlay.Hide();
if (DcConfig.Duty.OverlayClickThru)
enableOverlayClickThru();
// //
chkEnableSound.Checked = DcConfig.Duty.EnableSound; chkEnableSound.Checked = DcConfig.Duty.EnableSound;
@ -669,6 +678,10 @@ namespace DutyContent.Tab
return; return;
DcConfig.Duty.OverlayClickThru = chkOverlayClickThru.Checked; DcConfig.Duty.OverlayClickThru = chkOverlayClickThru.Checked;
if (DcConfig.Duty.OverlayClickThru)
enableOverlayClickThru();
else
disableOverlayClickThru();
SaveConfig(); 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));
}
}
} }
} }