Merge pull request #5 from Jaehyuk-Lee/click-through

Enable click-through
This commit is contained in:
ksh 2021-06-06 16:52:56 +09:00 committed by GitHub
commit 8f4baef063
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 39 additions and 6 deletions

View file

@ -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);
}

View file

@ -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));
}
}
}
}