Solved

wait user action in Delphi

Posted on 2011-03-08
4
486 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
  • 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

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi XE2 application frozen on Windows 10 10 311
code issue 8 130
Find and Replace Stream with 0s 8 62
FMX and jaudiotracker playing memory stream 29 78
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

770 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