Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more: (untagged)
Hello there guys.

The reason why I am building this tool, is just so that every one logged into windows 2003 can chat at work, about business, customers etc etc.

The tool works 100% in windows XP.
and 90% on windows server..

This is what the tool does...

Sends Message, changes string from 1 to 0... Timmer checks, if string = zero, && window is not active, notification window appears.

well...

in windows 2003, everything works , except the notification window doesnt appear.

Maybe im doing something not compatible...




C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Timers;
using System.IO;
//using System.Drawing;

   
namespace CC
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

            
        }

        //public string BalloonTipText;



        private void SetBalloonTip()
        {
            notifyIcon1.Icon = SystemIcons.Asterisk;
            notifyIcon1.BalloonTipTitle = "NEW MESSAGE";
            notifyIcon1.BalloonTipText = "A new message has arrived.";
            notifyIcon1.BalloonTipIcon = ToolTipIcon.Info;
            //this.Click += new EventHandler(Form1_Click);
            //this.Activated += new EventHandler(Form1_Click);
            //Form1_Click(EventArgs e);
            _showmenu();
        }

        void _showmenu()
        {
            notifyIcon1.Visible = true;
            notifyIcon1.ShowBalloonTip(10000);
        
        }
        void Form1_Click(object sender, EventArgs e)
        {
            notifyIcon1.Visible = true;
            notifyIcon1.ShowBalloonTip(5000);

        }
        


        //Ok lets do this...

        private static System.Timers.Timer TT1;
        private static System.Timers.Timer TT2;
        private static System.Timers.Timer TT3;
        private static System.Timers.Timer TT4;
        
        string _nmsg ="0";
        


       

        private void Form1_Load(object sender, EventArgs e)
        {

            try
            {
                TT3 = new System.Timers.Timer(5000);
                TT3.Elapsed += new ElapsedEventHandler(_event3);
                TT3.Interval = 5000;
                TT3.Enabled = true;
            }
            catch
            {
            }
           /* try
            {
                TT4 = new System.Timers.Timer(5000);
                TT4.Elapsed += new ElapsedEventHandler(_event4);
                TT4.Interval = 2;
                TT4.Enabled = true;
            }
            catch
            {
            }
            */




            try
            {
                TT1 = new System.Timers.Timer(5000);
                TT1.Elapsed += new ElapsedEventHandler(_event1);
                TT1.Interval = 5000;
                TT1.Enabled = true;
            }
            catch
            {
            }

            try
            {
                TT2 = new System.Timers.Timer(5000);
                TT2.Elapsed += new ElapsedEventHandler(_event2);
                TT2.Interval = 5000;
                TT2.Enabled = true;

            }
            catch
            {
            }
        }
        private void BTNclose_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void Form1_Resize(object sender, System.EventArgs e)
        {
            if (FormWindowState.Minimized == WindowState)
                Hide();
        }

        private void notifyIcon1_DoubleClick(object sender,
                                     System.EventArgs e)
        {
            Show();
            WindowState = FormWindowState.Normal;
        }
        public void _event3(object source, ElapsedEventArgs e)
        {

            try
            {                
                this.EndInvoke(this.BeginInvoke(new MethodInvoker(delegate()
                    {
                        StreamReader xcheck = new StreamReader("xcheck2.txt");
                        TBnmsg.Text = xcheck.ReadToEnd();
                        xcheck.Close();
                        _nmsg = TBnmsg.Text;
                    })));
            }
                catch
            {
            }
                if (_nmsg == "0")
                {
                    if (Form.ActiveForm == this)
                    {
                        
                    }
                    else
                    {
                        SetBalloonTip();

                    }

                    try
                    {
                        this.EndInvoke(this.BeginInvoke(new MethodInvoker(delegate()
                            {
                                /*   StreamWriter streamwriter2;
                                   streamwriter2 = File.CreateText("xcheck.txt");
                                   streamwriter2.WriteLine("0");
                                   streamwriter2.Close();*/

                                String strFile = File.ReadAllText("xcheck2.txt");
                                strFile = strFile.Replace("0", "1");
                                File.WriteAllText("xcheck2.txt", strFile);
                            })));
                    }
                    catch
                    {
                    }
                }
                else
                {
                }
                
        }

        public void _event4(object source, ElapsedEventArgs e)
        {
        }

        public void _event1(object source, ElapsedEventArgs e)
        {
            try
            {

                this.EndInvoke(this.BeginInvoke(new MethodInvoker(delegate()
                {
                    StreamReader STNEXUS = new StreamReader("quadaxial.txt");
                    TBnexus.Text = STNEXUS.ReadToEnd();
                    STNEXUS.Close();

                    //move the caret to the end of the text
                    TBnexus.SelectionStart = TBnexus.TextLength;
                    //scroll to the caret
                    TBnexus.ScrollToCaret();

                })));



            }
            catch
            {
            }
                

            }
            
      
        string _user = Environment.UserName;
         
        

        public void _event2(object source, ElapsedEventArgs e)
        {
           
        }

    

        private void tb_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                

                _enter();
            }
        }

        private void _enter()
        {
            
            if (TBmessage.Text != "")
            {

                try
                {
                    this.EndInvoke(this.BeginInvoke(new MethodInvoker(delegate()
                {
                    String strFile = File.ReadAllText("xcheck2.txt");
                    strFile = strFile.Replace("1", "0");
                    File.WriteAllText("xcheck2.txt", strFile);
                })));
                }
                catch
                { }

                try
                {
                    this.EndInvoke(this.BeginInvoke(new MethodInvoker(delegate()
                    {
                        StreamWriter streamwriter;
                        streamwriter = File.AppendText("quadaxial.txt");
                        streamwriter.WriteLine(_user + ": " + TBmessage.Text + "\r\n");
                        streamwriter.Close();
                        TBmessage.Text = "";

                    })));
                }
                catch
                {
                }
            }

            else
            {
                MessageBox.Show("No message to send,Message Box is EMPTY");
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
           /* this.EndInvoke(this.BeginInvoke(new MethodInvoker(delegate()
                           {
                               StreamWriter streamwriter2;
                               streamwriter2 = File.AppendText("xcheck2.txt");
                               streamwriter2.WriteLine("0");
                               streamwriter2.Close();
                           })));*/
            
            _enter();

            
        }

        private void button2_Click(object sender, EventArgs e)
        {
            
StreamReader streamreader1 = new StreamReader("quadaxial.txt");
TBhistory.Text  = streamreader1.ReadToEnd();
streamreader1.Close();

            panel2.Visible = true;
            BTNback.Visible = true;
            BTNclose.Visible = false;
            panel1.Visible = false;
        }

        private void BTNback_Click(object sender, EventArgs e)
        {
            panel2.Visible = false;
            BTNback.Visible = false;
            BTNclose.Visible = true;
            panel1.Visible = true;
        }
        
    }
}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900