Skip to content

Commit

Permalink
patch form still being listed in Alt-Tab
Browse files Browse the repository at this point in the history
requires the form flash on-screen at load for a millisecond, but that's probably fine tbh
  • Loading branch information
mcmonkey4eva committed Aug 6, 2019
1 parent 1e492b4 commit 928e164
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions KeyboardChatterBlocker/MainBlockerForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,23 @@ public partial class MainBlockerForm : Form
/// <summary>
/// Whether the form is currently hidden from view.
/// </summary>
public bool IsHidden => !ShowInTaskbar;
public bool IsHidden => !Visible;

/// <summary>
/// Shows the form fully and properly.
/// There are some issues with how Windows Forms handles hidden forms, this is to compensate for those.
/// </summary>
public void ShowForm()
{
WindowState = FormWindowState.Normal;
ShowInTaskbar = true;
Visible = true;
}

/// <summary>
/// Hides the form fully and properly.
/// There are some issues with how Windows Forms handles hidden forms, this is to compensate for those.
/// </summary>
public void HideForm()
{
WindowState = FormWindowState.Minimized;
ShowInTaskbar = false;
TrayIcon.Visible = true;
Visible = false;
}

/// <summary>
Expand All @@ -59,7 +56,8 @@ public MainBlockerForm()
{
if (Program.HideInSystemTray)
{
HideForm();
WindowState = FormWindowState.Minimized;
ShowInTaskbar = false;
}
Program.Blocker.KeyBlockedEvent += LogKeyBlocked;
InitializeComponent();
Expand Down Expand Up @@ -162,7 +160,18 @@ public void MainBlockerForm_Load(object sender, EventArgs e)
TrayIconCheckbox.Checked = Program.HideInSystemTray;
if (Program.HideInSystemTray)
{
WindowState = FormWindowState.Minimized;
ShowInTaskbar = false;
TrayIcon.Visible = true;
Timer hideProperlyTimer = new Timer() { Interval = 100 };
hideProperlyTimer.Tick += (tickSender, tickArgs) =>
{
WindowState = FormWindowState.Normal;
ShowInTaskbar = true;
Visible = false;
hideProperlyTimer.Stop();
};
hideProperlyTimer.Start();
}
ChatterThresholdBox.Value = Program.Blocker.GlobalChatterTimeLimit;
EnabledCheckbox.Checked = Program.Blocker.IsEnabled;
Expand Down

0 comments on commit 928e164

Please sign in to comment.