1 Replies - 360 Views - Last Post: 06 October 2011 - 11:37 PM Rate Topic: -----

#1 adn258  Icon User is offline

  • D.I.C Addict

Reputation: 4
  • View blog
  • Posts: 529
  • Joined: 31-August 11

My Application Is Not Using Timer Functions When Minimized to Tray?

Posted 06 October 2011 - 07:08 PM

CORRECTION TO THE SUBJECT SORRY MY KEYBOARD is nutty. It's
My Application Is Not USING THE Timer Functions When Minimized To Tray?


So I have an application that works JUST FINE when it's open and running but not when I use my TO-TRAY application code. The application is built on a timer that checks the users current IP address vs's it's IP when last checked. If there is a change in the IP address this is emailed to the user so the user constantly knows what his or her WAN IP is.

 public void Totray()
        {
           
            this.WindowState = FormWindowState.Minimized;

            if (FormWindowState.Minimized == this.WindowState)
            {
                notifyIcon1.Visible = true;
                
                this.Hide();
                
            }
            else if (FormWindowState.Normal == this.WindowState)
            {
                notifyIcon1.Visible = false;
            }


        }


If the function that is used when the user clicks the MINIMIZE TO TRAY button. It Works fine and it shows my notify icon. Then my notify icon uses


private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (FormWindowState.Minimized == this.WindowState)
            {

                notifyIcon1.Visible = false;
                this.Show();
                this.WindowState = FormWindowState.Normal;

            }
        }


This also works just fine when you want to re-show the application. I could just use this.hide(); instead of the minimize WHICH also works only it doesn't allow my program to update and there is the problem.

This application goes to the tray but instead of checking the external web site source for WAN IP Updates it does NOTHING until the application windows is back to normal so the user can see it? This doesn't make any sense wouldn't the application do the same thing if it's hidden?





I don't know that this will help without the entire application and I don't THINK IT IS A FACTOR IN This at all but the IP update stuff is doen via



//important infinite loop program timer that occurs periodically
        private void timer1_Tick(object sender, EventArgs e)
        {
            //set this equal to false since we are already logging the IP with the seperate function the button shouldn't be doing this only if the user clicks it this will need to
            //be set back to true though after the tick
            Bool_DidUserClickUpdate = false;
           
            //Store Last IP in LastIPChecked Which is used as a read only backup text box to hold the string IP so we can compare the curret updated IP in the next step
            LastIPChecked.Text = _IPTxtBox.Text;

            //update IP Fucntion To current WAN IP which we will compare to LASTIP CHECKED IPTxtBox.text
            _UpdateIPBtn.PerformClick();


            //comparing the two changeable strings in the text box; if the last IP checked doesn't equal the 
            //last current WAN IP i.e. if it does NOT equal zero - We will carry out our next steps
            if (string.Compare(_IPTxtBox.Text, LastIPChecked.Text) != 0)
            {
                //use the send email function
                SendEmailTime();

                //Lastly UPdate the IPLog.txt File With IP History using this fucntion since it won't be updated the same way as if the user clicks the update btn i.e. 2 different strings
                IPToLogFile();

                //If The Main Forum is Minimized
                if (FormWindowState.Minimized == this.WindowState)
                {
                    notifyIcon1.BalloonTipText = "Your IP Has Changed";
                    notifyIcon1.BalloonTipTitle = "IP Changed";
                    notifyIcon1.BalloonTipIcon = ToolTipIcon.Info;
                }
                //lastly set the bool back to true for deciding which string with the IP will go to the log file
                Bool_DidUserClickUpdate = true;

          }
            //update notify icon
            this.notifyIcon1.Text = "IP Time WAN IP " + _IPTxtBox.Text;
            Bool_DidUserClickUpdate = true;
      
}


        //main function to use for sending emails throughout the program
        public void SendEmailTime()
        {

            //try sending an email
            try
            {

                //Decide if The User Wants To Use a Custom Email Message Bassed on The Radio Btn's Being Checked
                if (_UseDefaultEmailRadioBtn.Checked == true)
                {
                    //Send The New IP With the DEFAUL Email Subject
                    IPTimeFunc.IPAddresses.EmailSubject = "Your WAN IP Has Updated";

                    //Send The New IP With The DEFAULT Email Body;
                    IPTimeFunc.IPAddresses.EmailBody = _IPTxtBox.Text + "\t Is Your New WAN IP Address As Detected.  Thank You For Using This Program..Have a Wonderful Day";
                }
                //if the user is using a custom email settings
                else if (_UseCustomEmailRadioBtn.Checked == true)
                {
                    //Send The New IP With the DEFAUL Email Subject
                    IPTimeFunc.IPAddresses.EmailSubject = _EmailSubjectBox.Text;

                    //Send The New IP With The DEFAULT Email Body;
                    IPTimeFunc.IPAddresses.EmailBody = _EmailBodyBox.Text + "\t" + "Your New IP Is" + _IPTxtBox.Text;

                }

                //Now That The Strings Are Set Send Email To User, using the void fucntion
                IPTimeFunc.IPAddresses.SendIPToEmail();
            }
            catch
            {

                MessageBox.Show("It Appears That Something Has Been Entered Incorrectly, Please Check All The User Information Again Like The Email Address, Password Etc.", "Something Is Wrong", MessageBoxButtons.OK, MessageBoxIcon.Warning);

            }

       }




For the what it's worth department. Any idea on why this isn't working when it's hidden and in the Tray i.e. the Timer etc.? Doesn't make sense to me.

This post has been edited by adn258: 06 October 2011 - 07:09 PM


Is This A Good Question/Topic? 0
  • +

Replies To: My Application Is Not Using Timer Functions When Minimized to Tray?

#2 adn258  Icon User is offline

  • D.I.C Addict

Reputation: 4
  • View blog
  • Posts: 529
  • Joined: 31-August 11

Re: My Application Is Not Using Timer Functions When Minimized to Tray?

Posted 06 October 2011 - 11:37 PM

Okay sorry people I finally found the answer to this question. I was using a Performbuttonclick() function within my event of the timer click -- for whatever reason this WON'T work once the application is hidden using this.Hide();

Which works fine for what I want but it won't use the rest of the code. The solution is I just used in a function for the timer what would have been used in a button click. Problem solved the notify icon even shows it's Balloon message etc.

Peace
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1