Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 514
  • Last Modified:

wait user action in Delphi

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
LeTay
Asked:
LeTay
  • 2
1 Solution
 
ThommyCommented:
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
 
LeTayAuthor Commented:
More simple than that is difficult !
Many thanks Tommy
0
 
Geert GruwezOracle dbaCommented:
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
 
Geert GruwezOracle dbaCommented:
ah it was closed already ...
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now