Solved

designing the execute method in a dialog

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

Independent Software Vendors: 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
Comparing dates in Delphi. Greater than/ Less than 3 295
RESTRequest Parameter 4 53
Wincontrol not (correctly) drawn 15 47
IP without any Dots 1 53
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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…

756 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