?
Solved

designing the execute method in a dialog

Posted on 1998-06-05
3
Medium Priority
?
222 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 160 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

764 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