473,411 Members | 1,880 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

...How can I make a button to stop the process of another button?

Hi all

I have the following code: a line is growing up by clicking on "up" button, it has another button"start" which I want it to stop the process of growing the line...How can I make a button to stop the process of another button?


class Program: Form
{
int x1;
int y1;
int x2;
int y2;
Button up = new Button();
Button start = new Button();
public Program()
{
Size=new Size(800,800);
x1 = 365;
y1 = 280;
x2 = 365;
y2 = 280;

/*Create Buttons*/


up.Text = "Up";
up.Click += new EventHandler(up_Click);
up.Location = new Point(340, 550);
up.Size = new Size(100, 40);

this.Controls.Add(up);


start.Text = "Start/"+"\n"+"Pause";
start.Click += new EventHandler(start_Click);
start.Location = new Point(340, 600);
start.Size = new Size(100, 40);
this.Controls.Add(start);

this.Paint += new PaintEventHandler(myform_Paint);

}
void up_Click(object sender, EventArgs e)
{
AnimateUp();
}

void start_Click(object sender, EventArgs e)
{
AnimateStart();
}

private void AnimateUp()
{

if (start.Text == "Assume")
start.Text = "Pause";

{
while (y2 > 24)
{

y2 = y2 - 10;
this.Invalidate();
this.Refresh();
System.Threading.Thread.Sleep(100);
}
x1 = x2;
y1 = y2;
MessageBox.Show("Game Over!!", "End of the game", MessageBoxButtons.OKCancel);
Application.Exit();
}
}

private void AnimateStart()
{


if (start.Text == "Start/" + "\n" + "Pause")
start.Text = "Pause";

else if (start.Text == "Pause")
start.Text = "Assume";
}

private void myform_Paint( object sender,PaintEventArgs e)
{
Graphics g = e.Graphics;
Brush brush = new SolidBrush(Color.Black);
Pen pen = new Pen(brush, 4);
g.DrawRectangle(pen, 20, 20, 750, 500);

g.DrawLine(pen, x1, y1,x2, y2);
}


static void Main(string[] args)
{
Application.Run(new Program());
Application.Exit();
}
Oct 26 '07 #1
3 1815
radcaesar
759 Expert 512MB
First tell your requirement clearly before give the code.
Oct 26 '07 #2
Plater
7,872 Expert 4TB
Please don't double post. Your question was already being worked on here:
http://www.thescripts.com/forum/thread728672.html
Oct 26 '07 #3
I think I am clear..
Oct 26 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Mullin Yu | last post by:
I want to create a C# GUI application that will start a new console application, e.g. console.exe when clicking a button. Then, if click a button, it will kill a specific console application. Am...
12
by: Vadym Stetsyak | last post by:
Hi there! Is there any way how can I stop garbage collection for a period of time. Lets say, I have a form. Before form load I pause the GC and when the form is shown resume GC
7
by: MgGuigg | last post by:
Hello all, This is my first time posting a question to this forum, so here is hoping I am following protocol. I am scraping the rust off my old Basic programming skills, and have just recently...
3
by: LDD | last post by:
Hey folks I have some interesting behaviour going in. Inside a form, I download some data. The form is used to show the status, and set button states etc... I have a break point set up at...
7
by: jab3 | last post by:
Hello. I'm wondering if someone can answer something I'm sure has been answered a thousand times before. I am apparently just too dumb to find the answer. :) I've found information about the...
1
by: AE_Cory | last post by:
I'm a n00b to Visual C++ and OOP, but not to programming in general. Here's the problem: Not knowing what I'm doing, I've made my VC++ application as a CLR Window Forms project. Now, I have a...
8
by: Richard Maher | last post by:
Hi, I am in a mouseup event for button A and I'd like to disable=false button B before starting some work. Is there anyway that an event for button B can then fire before my event processing for...
12
by: Flan | last post by:
I am running on a Mac, with FlashCS3, using Actionscript 3.0. First I'm going to say that I am really new to Actionscript. (As in, only been using for a few days new.) So please excuse me if I...
4
by: tshad | last post by:
I have an executable that has a button that I want to change the name of to "Now Processing...". When the process is done, I want to change it back. The problem is that the form is not showing...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.