Solved

designing the execute method in a dialog

Posted on 1998-06-05
3
215 Views
Last Modified: 2010-04-06
I want to design a dialog component that with an execute method like in Delphi own dialog. When I call :
if dialog.execute then
...

I want to program to wait in the dialog until the user press the ok button. How can I do that??
0
Comment
Question by:pjroy
  • 2
3 Comments
 
LVL 1

Accepted Solution

by:
Marcius earned 40 total points
ID: 1350722
This is simple answer. I once had to solve this problem, and came to a solution using threads and wait for events etc. However, I have a simple solution for you.

function MyDialogue.Execute : boolean;
begin

  //Set up code here

  //Whatever code you want here

  Result := (ShowModal = mrOk);

end;

Then set the modal result value of your button to mrOk. Your dialogue will process the execute method, reach the ShowModal call, then allow your user to play with the dialogue whilst it waits for a modal result.

Yes ! It really is that simple :)
0
 

Author Comment

by:pjroy
ID: 1350723
Ok, I have deleted the ok botton. My dialog is a form with no border containing a DBGrid. The user can press ESC to quit, the arrow to browse a record, and enter to select it and quit.

How can I do the same thing than with the button but without having a button on my form.
0
 
LVL 1

Expert Comment

by:Marcius
ID: 1350724
You can set ModalResult anywhere in your code, it doesn't have to be bound to a button.

e.g.

  if Count > 0 then ModalResult = true;

This will have the same effect as tying the result to a button press. This is really much more simple than you thought isn't it ?
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This video discusses moving either the default database or any database to a new volume.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

758 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now