I am trying to make an application with hotkeys and an option to startup in the taskbar tray.
Now the problem is, that using this.Hide()
in the load event, won't have any effect. I can add this.ShowInTaskbar = false
, but after I set it on true again, to show the window, it disables my hotkey out of itself.
Is there an other way to hide my form on startup, or to prevent my hotkey from unregistering?
My code to hide the form:
private void frmMain_Load(object sender, EventArgs e)
{
if (StartBG())
{
this.Hide();
this.ShowInTaskbar = false;
notifyIcon.Visible = true;
notifyIcon.ShowBalloonTip(3000, "Kore screenshots", "The application is started and will run on the background.", ToolTipIcon.Info);
}
}
After the code above, the hotkey still works,
private void showform()
{
this.Show();
this.ShowInTaskbar = true;
notifyIcon.Visible = false;
this.WindowState = FormWindowState.Normal;
}
After this code, the hotkey is disabled.
What I've done in the past is to create a separate form, which is always minimized and ShowInTaskbar false (so it's never user visible), and this form owns the NotyifyIcon.
Then, any UI I want to display, I develop as separate forms which I show/hide as required. I find this works more cleanly than trying to get one form which might be shown/hidden/showing in taskabr/owning a notifyicon.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With