C# Programming
11-07-2009, 06:42 AM
Hi all,
writing a small app that reads a registry setting and based on the content on that, should either show the form or hide it in the tray bar.
RegistryKey masterKey = Registry.LocalMachine.CreateSubKey("SOFTWARE\\Policies\\OTM");
if (masterKey != null)
{
if (masterKey.GetValue("Serial").ToString().Length == 36)
{
textBox1.Text = masterKey.GetValue("Serial").ToString();
textBox1.Enabled = false;
this.Hide();
}
else
{
textBox1.Enabled = true;
this.StartPosition = FormStartPosition.CenterScreen;
this.WindowState = FormWindowState.Normal;
this.Show();
}
}
unfortunately the window always stays open. Anyone who have a quick tip to what Im missing?
I tried to include this.WindowState = FormWindowState.Minimized;, but that just minimized to app, but didnt hide it in the tray bar. - sorry writing error here. Meant didnt hide the form at all. At best it gets to be minimized in the lower left corner.
modified on Friday, November 6, 2009 4:27 AM
writing a small app that reads a registry setting and based on the content on that, should either show the form or hide it in the tray bar.
RegistryKey masterKey = Registry.LocalMachine.CreateSubKey("SOFTWARE\\Policies\\OTM");
if (masterKey != null)
{
if (masterKey.GetValue("Serial").ToString().Length == 36)
{
textBox1.Text = masterKey.GetValue("Serial").ToString();
textBox1.Enabled = false;
this.Hide();
}
else
{
textBox1.Enabled = true;
this.StartPosition = FormStartPosition.CenterScreen;
this.WindowState = FormWindowState.Normal;
this.Show();
}
}
unfortunately the window always stays open. Anyone who have a quick tip to what Im missing?
I tried to include this.WindowState = FormWindowState.Minimized;, but that just minimized to app, but didnt hide it in the tray bar. - sorry writing error here. Meant didnt hide the form at all. At best it gets to be minimized in the lower left corner.
modified on Friday, November 6, 2009 4:27 AM