G
Guest
I'm new to c# and am currently developing a small login/logout app that runs
in the system tray. I am trying to get it to access a website during system
shutdown, but it doesn't seem to want to.
//catch message from windows on shutdown
protected override void WndProc(ref Message m)
{
if (m.Msg == 0x11)
{
this.flagBoolean1 = true; //set flag for closing app OK
string currentUrl = webBrowser1.Url;
if (currentUrl.Contains("webpage1"))
webBrowser1.Navigate("webpage2");
else Shutdown();
}
base.WndProc(ref m);
}
//the close form cancel function for system tray app
private void Form1_Closing(object sender,
System.ComponentModel.CancelEventArgs e)
{
//really close app?
if (!flagBoolean1)
{
e.Cancel = true;
this.Visible = false;
}
else
{
string currentUrl = webBrowser1.Url;
//tried the web navigation at both locations to no avail
if (currentUrl.Contains("webpage1"))
{
webBrowser1.Navigate("webpage2");
}
Shutdown();
}
}
private void Shutdown()
{
this.WindowState = System.Windows.Forms.FormWindowState.Normal;
this.notifyIcon1.Visible = false;
this.Dispose();
Application.Exit();
this.Close();
}
in the system tray. I am trying to get it to access a website during system
shutdown, but it doesn't seem to want to.
//catch message from windows on shutdown
protected override void WndProc(ref Message m)
{
if (m.Msg == 0x11)
{
this.flagBoolean1 = true; //set flag for closing app OK
string currentUrl = webBrowser1.Url;
if (currentUrl.Contains("webpage1"))
webBrowser1.Navigate("webpage2");
else Shutdown();
}
base.WndProc(ref m);
}
//the close form cancel function for system tray app
private void Form1_Closing(object sender,
System.ComponentModel.CancelEventArgs e)
{
//really close app?
if (!flagBoolean1)
{
e.Cancel = true;
this.Visible = false;
}
else
{
string currentUrl = webBrowser1.Url;
//tried the web navigation at both locations to no avail
if (currentUrl.Contains("webpage1"))
{
webBrowser1.Navigate("webpage2");
}
Shutdown();
}
}
private void Shutdown()
{
this.WindowState = System.Windows.Forms.FormWindowState.Normal;
this.notifyIcon1.Visible = false;
this.Dispose();
Application.Exit();
this.Close();
}