TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
ng_jeffrey
NA
5
0
Anyone has made blinking button before?
Aug 25 2004 10:17 AM
Hi I am a beginner in this language. I have tried to make blinking button but seems that my code is not correct. Here is my lousy code: Form1.cs: using System; using System.Drawing; using System.Windows.Forms; using System.Timers; using System.Collections; using System.ComponentModel; using System.Data; namespace bLINKINGbUTTON2 { public class Form1 : Form { public Panel panel1; public Button cmdABC; public Button cmdDEF; public Form1() { this.Name = "Form1"; this.Text = "Form1"; this.Load += new System.EventHandler(this.Form1_Load); //Set the size of the Client Rectangle this.ClientSize = new System.Drawing.Size(500, 500); panel1 = new Panel(); // Initialize the Panel control. panel1.Location = new Point(10,10); panel1.Size = new Size(400, 300); // Set the Borderstyle for the Panel to three-dimensional. panel1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; //Generate alphabetic buttons cmdABC=new Button(); cmdABC.Text=" A B C "; cmdABC.Location=new Point(24,40); cmdABC.Size =new Size(128,48); cmdABC.Visible = true; cmdABC.Enabled = true; cmdDEF=new Button(); cmdDEF.Text=" D E F "; cmdDEF.Location=new Point(200,40); cmdDEF.Size =new Size(128,48); // Add the Panel control to the form. this.Controls.Add(panel1); // Add the Button controls to the Panel. panel1.Controls.Add(cmdABC); panel1.Controls.Add(cmdDEF); } static void Main() { Application.Run(new Form1()); } private void Form1_Load(object sender, System.EventArgs e) { Connection myConnection = new Connection(); myConnection.Connect(); } } } Connection.cs: using System; using System.Timers; using System.Drawing; using System.Windows.Forms; using System.Collections; using System.ComponentModel; using System.Data; namespace bLINKINGbUTTON2 { public class Connection:Form1 { private System.Timers.Timer pollTimer; public Connection() { pollTimer = new System.Timers.Timer(5000); pollTimer.Elapsed += new ElapsedEventHandler(CheckForMessage); } public void Connect() { pollTimer.Start(); } public void Disconnect() { pollTimer.Stop(); } private void CheckForMessage (object source, ElapsedEventArgs e) { this.cmdABC.BackColor = Color.BurlyWood; this.cmdABC.BackColor = System.Windows.Forms.Form.DefaultBackColor; this.cmdDEF.BackColor = Color.Red; this.cmdDEF.BackColor = System.Windows.Forms.Form.DefaultBackColor; } } } Any help will be much appreciated. Thank you before!
Reply
Answers (
5
)
Process.MainWindowTitle
Screen Resolution