473,583 Members | 3,010 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

17 New Member
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.A dd(up);


start.Text = "Start/"+"\n"+"Pau se";
start.Click += new EventHandler(st art_Click);
start.Location = new Point(340, 600);
start.Size = new Size(100, 40);
this.Controls.A dd(start);

this.Paint += new PaintEventHandl er(myform_Paint );

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

void start_Click(obj ect 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.Threadin g.Thread.Sleep( 100);
}
x1 = x2;
y1 = y2;
MessageBox.Show ("Game Over!!", "End of the game", MessageBoxButto ns.OKCancel);
Application.Exi t();
}
}

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,PaintEve ntArgs e)
{
Graphics g = e.Graphics;
Brush brush = new SolidBrush(Colo r.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.Exi t();
}
Oct 26 '07 #1
3 1831
radcaesar
759 Recognized Expert Contributor
First tell your requirement clearly before give the code.
Oct 26 '07 #2
Plater
7,872 Recognized Expert Expert
Please don't double post. Your question was already being worked on here:
http://www.thescripts.com/forum/thread728672.html
Oct 26 '07 #3
shimajavar
17 New Member
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
5927
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 I right that I need to create a new thread when clicking a "Start Button" for starting a console application. And, a separating thread of "Stop...
12
2263
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
2570
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 upgraded to VB.NET, and I have a lot of catching up to do. That being said, I have come a long way in a short while, however, I am stumped at the...
3
1611
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 one of the button click event handlers. When the button is clicked, the application doesn't stop at the breakpoint for the click event. Nor does it...
7
2263
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 'onstop' event, but it's not behaving as expected. (And it also seems to be a proprietary attribute) That is, my defined function is not being run...
1
1713
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 process that is lauched by pushing a button. The code for this process is inside the Button_Click event handler for that particular button. The...
8
2024
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 button A's mouseup has completed? I beleive event processing to be single-threaded for good reason but I need a "stop" button and it's no good if...
12
10404
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 don't have the terminology down completely. I am trying to create an interactive button where upon "rolling over" a certain movie clip is played, and...
4
1692
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 the new name. I assume I would need to flush it somehow to get the display to show. The code is:
0
7895
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7826
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8182
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7935
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8193
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6579
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5701
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3843
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1157
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.