Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Close form on a doubleclick

Posted on 1997-12-03
1
Medium Priority
?
160 Views
Last Modified: 2010-04-04
When I click the OK button, the form is closed, returning a mrOK. I want to do the same when a TListBox element is double-clicked. I thought to do that the following way:

When the OK button is pressed, the procedure OKBtnClick is called. When an element in the listbox is double clicked, the following procedure is called:

   procedure x.OnBoxDblClick (Sender: TObject);
   begin
      OKBtnClick(Sender)
   end;

However when I do this, the form is not closed. What am I doing wrong?
0
Comment
Question by:ble
1 Comment
 
LVL 5

Accepted Solution

by:
julio011597 earned 400 total points
ID: 1352794
That's because your OK button has a ModalResult property which is not related to its handler.

To do the same with your ListBox change its handler to something like this:

--//--
procedure x.OnBoxDblClick(Sender: TObject);
begin
  OKBtnClick(Sender); // or any other code
  ModalResult := True;
end;
--//--

Look for ModalResult Property into the Delphi Help File.

Regards.
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

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…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Loops Section Overview

782 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