Solved

wait user action in Delphi

Posted on 2011-03-08
4
495 Views
Last Modified: 2012-05-11
I am developping Delphi GUI application
That application process "commands" that come from a "script" (via a for loop)
Some commands request the user to do some "action"
For example, the user has to confirm something : I do this with a "modal" request.
But now, some command requests the user to click on a button on the form.
Only when the user will click on that will the "process" continue its execution.
Another command "asks" the user to drag and drop something on the form
Etc..
What is the easiest way to achieve this ? (events, timer, flags ...)
A sample is welcome...
0
Comment
Question by:LeTay
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 19

Accepted Solution

by:
Thommy earned 500 total points
ID: 35068287
1.) Set global variable, when your script reaches the point, where user interaction is required
STOP:=true;

2.) Pause your script in a WHILE loop
WHILE Stop do begin
  Application.ProcessMessages;
end;

3.) If user has done his work, reset global variable in OnClick or OnDrag events to continue your script
STOP:=false;
0
 

Author Closing Comment

by:LeTay
ID: 35068735
More simple than that is difficult !
Many thanks Tommy
0
 
LVL 37

Expert Comment

by:Geert Gruwez
ID: 35069320
it all depends on how you have setup your script to run

let's assume that you want feedback from the script ... it's progress
and that you want a responsive app
and you want user input via the front-end

you still need to divide the script in 2 divisions
1: all user input is asked before the script starts
2: user input depends on results from inside the script

from all the apps i have written/maintained,
having to use application.processmessages indicates a flaw in design

threads are the best approach to solve this problem
and syncronisation objects to control the flow
0
 
LVL 37

Expert Comment

by:Geert Gruwez
ID: 35069332
ah it was closed already ...
0

Featured Post

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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi Firemonkey Need Sample for Online Shopping Example. 2 220
creating threads in delphi 1 204
Delphi Yen format 3 76
can i put an image from resource into image tag ? 6 42
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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

710 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