Ask a questionAsk a question
 

Answerc#

  • Saturday, November 07, 2009 7:46 AMprincess_980 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I have a application program in c#.net.(users can send private messages to eachother in this program).I want to alarm the user that works with it and logged on it that have a new message.
    alarm like when recieved a new email.
    thanks

Answers

  • Saturday, November 07, 2009 7:56 AMTamer OzMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     AnswerHas Code
    namespace WindowsFormsApplication1
    {
        partial class Form8
        {
            /// <summary>
            /// Required designer variable.
            /// </summary>
            private System.ComponentModel.IContainer components = null;
    
            /// <summary>
            /// Clean up any resources being used.
            /// </summary>
            /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
            protected override void Dispose(bool disposing)
            {
                if (disposing && (components != null))
                {
                    components.Dispose();
                }
                base.Dispose(disposing);
            }
    
            #region Windows Form Designer generated code
    
            /// <summary>
            /// Required method for Designer support - do not modify
            /// the contents of this method with the code editor.
            /// </summary>
            private void InitializeComponent()
            {
                this.lblTitle = new System.Windows.Forms.Label();
                this.lblMessage = new System.Windows.Forms.Label();
                this.lblClose = new System.Windows.Forms.Label();
                this.SuspendLayout();
                // 
                // lblTitle
                // 
                this.lblTitle.AutoSize = true;
                this.lblTitle.Location = new System.Drawing.Point(0, 0);
                this.lblTitle.Name = "lblTitle";
                this.lblTitle.Size = new System.Drawing.Size(27, 13);
                this.lblTitle.TabIndex = 0;
                this.lblTitle.Text = "Title";
                // 
                // lblMessage
                // 
                this.lblMessage.AutoSize = true;
                this.lblMessage.Location = new System.Drawing.Point(0, 27);
                this.lblMessage.Name = "lblMessage";
                this.lblMessage.Size = new System.Drawing.Size(28, 13);
                this.lblMessage.TabIndex = 1;
                this.lblMessage.Text = "Text";
                // 
                // lblClose
                // 
                this.lblClose.AutoSize = true;
                this.lblClose.Location = new System.Drawing.Point(289, 0);
                this.lblClose.Name = "lblClose";
                this.lblClose.Size = new System.Drawing.Size(14, 13);
                this.lblClose.TabIndex = 2;
                this.lblClose.Text = "X";
                this.lblClose.Click += new System.EventHandler(this.lblClose_Click);
                // 
                // Form8
                // 
                this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
                this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
                this.ClientSize = new System.Drawing.Size(303, 79);
                this.Controls.Add(this.lblClose);
                this.Controls.Add(this.lblMessage);
                this.Controls.Add(this.lblTitle);
                this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
                this.Name = "Form8";
                this.Text = "Form8";
                this.Load += new System.EventHandler(this.Form8_Load);
                this.ResumeLayout(false);
                this.PerformLayout();
    
            }
    
            #endregion
    
            private System.Windows.Forms.Label lblTitle;
            private System.Windows.Forms.Label lblMessage;
            private System.Windows.Forms.Label lblClose;
        }
    }
    
    Hi,

    You can open this form when new message arrived. It acts like a  notification window in outlook.

    Here is the code.

    Form8.cs
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    
    namespace WindowsFormsApplication1
    {
        public partial class Form8 : Form
        {
            public Form8()
            {
                InitializeComponent();
                
            }
            public string Title
            {
                get { return lblTitle.Text;}
                set { lblTitle.Text = value; }
            }
            public string Message
            {
                get { return lblMessage.Text; }
                set { lblMessage.Text = value; }
            }
            Timer t = new Timer();
            private void Form8_Load(object sender, EventArgs e)
            {
                this.Location = new Point(Screen.PrimaryScreen.Bounds.Width - this.Width - 20, Screen.PrimaryScreen.Bounds.Height - this.Height - 50);
                t.Interval = 500;
                t.Enabled = true;
                t.Tick += new EventHandler(t_Tick);
            }
    
            void t_Tick(object sender, EventArgs e)
            {
                this.Opacity -= 0.1;
                if (this.Opacity == 0)
                {
                    t.Enabled = false;
                    this.Close();
                }
            }
    
            private void lblClose_Click(object sender, EventArgs e)
            {
                this.Close();
            }
        }
    }
    
    


    Form8.designer.cs

All Replies

  • Saturday, November 07, 2009 7:56 AMTamer OzMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     AnswerHas Code
    namespace WindowsFormsApplication1
    {
        partial class Form8
        {
            /// <summary>
            /// Required designer variable.
            /// </summary>
            private System.ComponentModel.IContainer components = null;
    
            /// <summary>
            /// Clean up any resources being used.
            /// </summary>
            /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
            protected override void Dispose(bool disposing)
            {
                if (disposing && (components != null))
                {
                    components.Dispose();
                }
                base.Dispose(disposing);
            }
    
            #region Windows Form Designer generated code
    
            /// <summary>
            /// Required method for Designer support - do not modify
            /// the contents of this method with the code editor.
            /// </summary>
            private void InitializeComponent()
            {
                this.lblTitle = new System.Windows.Forms.Label();
                this.lblMessage = new System.Windows.Forms.Label();
                this.lblClose = new System.Windows.Forms.Label();
                this.SuspendLayout();
                // 
                // lblTitle
                // 
                this.lblTitle.AutoSize = true;
                this.lblTitle.Location = new System.Drawing.Point(0, 0);
                this.lblTitle.Name = "lblTitle";
                this.lblTitle.Size = new System.Drawing.Size(27, 13);
                this.lblTitle.TabIndex = 0;
                this.lblTitle.Text = "Title";
                // 
                // lblMessage
                // 
                this.lblMessage.AutoSize = true;
                this.lblMessage.Location = new System.Drawing.Point(0, 27);
                this.lblMessage.Name = "lblMessage";
                this.lblMessage.Size = new System.Drawing.Size(28, 13);
                this.lblMessage.TabIndex = 1;
                this.lblMessage.Text = "Text";
                // 
                // lblClose
                // 
                this.lblClose.AutoSize = true;
                this.lblClose.Location = new System.Drawing.Point(289, 0);
                this.lblClose.Name = "lblClose";
                this.lblClose.Size = new System.Drawing.Size(14, 13);
                this.lblClose.TabIndex = 2;
                this.lblClose.Text = "X";
                this.lblClose.Click += new System.EventHandler(this.lblClose_Click);
                // 
                // Form8
                // 
                this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
                this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
                this.ClientSize = new System.Drawing.Size(303, 79);
                this.Controls.Add(this.lblClose);
                this.Controls.Add(this.lblMessage);
                this.Controls.Add(this.lblTitle);
                this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
                this.Name = "Form8";
                this.Text = "Form8";
                this.Load += new System.EventHandler(this.Form8_Load);
                this.ResumeLayout(false);
                this.PerformLayout();
    
            }
    
            #endregion
    
            private System.Windows.Forms.Label lblTitle;
            private System.Windows.Forms.Label lblMessage;
            private System.Windows.Forms.Label lblClose;
        }
    }
    
    Hi,

    You can open this form when new message arrived. It acts like a  notification window in outlook.

    Here is the code.

    Form8.cs
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    
    namespace WindowsFormsApplication1
    {
        public partial class Form8 : Form
        {
            public Form8()
            {
                InitializeComponent();
                
            }
            public string Title
            {
                get { return lblTitle.Text;}
                set { lblTitle.Text = value; }
            }
            public string Message
            {
                get { return lblMessage.Text; }
                set { lblMessage.Text = value; }
            }
            Timer t = new Timer();
            private void Form8_Load(object sender, EventArgs e)
            {
                this.Location = new Point(Screen.PrimaryScreen.Bounds.Width - this.Width - 20, Screen.PrimaryScreen.Bounds.Height - this.Height - 50);
                t.Interval = 500;
                t.Enabled = true;
                t.Tick += new EventHandler(t_Tick);
            }
    
            void t_Tick(object sender, EventArgs e)
            {
                this.Opacity -= 0.1;
                if (this.Opacity == 0)
                {
                    t.Enabled = false;
                    this.Close();
                }
            }
    
            private void lblClose_Click(object sender, EventArgs e)
            {
                this.Close();
            }
        }
    }
    
    


    Form8.designer.cs