?
Solved

Wait to click on the button !

Posted on 2006-05-20
7
Medium Priority
?
627 Views
Last Modified: 2010-04-05
I have the folowing situation. I have code with while looop which call 1 procedure. In this procedure i need to put code that will wait for the user to click on the button and then continue working.

Example

while 1 do
call procedure

procedure begin
somthing
somthing
wait for user to click on the button and continue
somthing
end
0
Comment
Question by:65zgtre45rr
7 Comments
 
LVL 28

Expert Comment

by:2266180
ID: 16724219
there is evry little information and too many solutions to point you in teh right direction for your situation. so here are a few solutions:
- use a modal form that only has one or 2 buttons (like ok, cancel) and do a showmodal instead of the "wait for user to click on the button and continue"
- if the button doesn't have an event associated then:
write an onclick event handler in it set the variable isok to true;
assign the new onclick event handler to te buttons onclick event
(the above is done only once) now comes the while 1 do
set a variable isok to false;
instead of "wait for user to click on the button and continue" do:
while not isok do
begin
  application.processmessages;
  sleep(50);
end;
while 1 do is now finished
set the onclick event of the button to nil
- if the button has an event handler, do as above, but:
first save the event handler to say buttonclicksaved
after the while not isok do
if assigned(buttonclicksaved) then
  buttonclicksaved(this);// to call the saved event handler
at finish, instead of settting the button event to nil, set it to buttonclicksaved
0
 
LVL 17

Expert Comment

by:geobul
ID: 16724262
Hello,

>wait for user to click on the button and continue
=
ShowMessage('Click me');


If you're talking about a specific button somewhere on a form, give us a bit more details:
- what calls "while 1 do ..."?
- is it a member of the same form where the button is. Or it is a part of a standalone procedure?
- can the second procedure be a method of that form also?
- there might be more questions later on...

Regards, Geo
0
 

Author Comment

by:65zgtre45rr
ID: 16724544
All is on the same form, somthing like this: Start procedure will loop and in every loop will call Get, Get will do somthing then wait user to click on Button1 and then do somthing again.

procedure Get(var1, var2 : string);
begin
  do somthing
  do somthing
  wait use to click on the button which is on the same form
  do somthing
end;


procedure TfrmWork.Button1Click(Sender: TObject);
begin

 this is the on button click code
end;


procedure Start(var1, var2 : string);
begin
while 1 do
Get(var1, var);

end;
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Accepted Solution

by:
Scay7 earned 1500 total points
ID: 16725041
for that procedure start rather use a timer1 to loop the get procedure
then in get create a loop with "repeat" and application.processmessages, this
will allow the user to click the button thats on the same form in order for him to continue

example below
etc...


var carryon : boolean;  //global var

procedure TForm1.FormCreate(Sender: TObject);
begin
carryon := false;
end

procedure Get(var1, var2 : string);
begin
  do somthing
  do somthing
    repeat  
      if carryon = true then
      begin
      //wait use to click on the button which is on the same form
      end;
    application.processmessages;
    until carryon = true;  //now that carryon = true program can finish...
  do somthing
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
Get(var1, var2);
end;


procedure TfrmWork.Button1Click(Sender: TObject);
begin
carryon := true;
// this is the on button click code
end;

peace Scay7
0
 
LVL 5

Expert Comment

by:Scay7
ID: 16725050
Sorry forgot to mention that when the program is created the timer1 is enabled meaing every second (you can change this time) it will call the GET procedure and stay inside the loop until users interaction is clicked and the finish

Other wise

when putting the timer1 on the form make is enabled property disabled.
the use someother button to enabled the timer and start the get process

peace Scay7
0
 

Author Comment

by:65zgtre45rr
ID: 16725174
//wait use to click on the button which is on the same form

what do i need to put insted of this ?
0
 

Author Comment

by:65zgtre45rr
ID: 16725275
Problem solved
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month13 days, 8 hours left to enroll

750 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question