Solved

designing the execute method in a dialog

Posted on 1998-06-05
3
220 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
[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
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

734 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