PTRUSCOTT
asked on
Delphi 7: How to close a child form by double clicking on it
Dear Experts,
I have a form that pops up to invite the user to select from a list of options. The list is displayed as a grid inside a form. I want the user to be able to double click one of the rows to select that item and automatically close the child form that displays the grid.
I can work out how to generate the doubleclick event. In the Delphi 7 IDE I can get it to generate the following code for the child form:
procedure TForm4.NextGrid1DblClick(S ender: TObject);
begin
end;
However I am not sure how to make the child form return control to the parent form.
If I just click an OK button on the child form I can grab the user's selection with this code:
if (Form4.showmodal = mrOK) then
result:= Form4.NextGrid1.SelectedRo w
else
result:=-1;
How can I achieve a similar thing by double clicking.
In Visual C++ I could send a windows message with WM_CLOSE but I'm not sure how suitable this is in Delphi.
Sincerely,
Philip Truscott
I have a form that pops up to invite the user to select from a list of options. The list is displayed as a grid inside a form. I want the user to be able to double click one of the rows to select that item and automatically close the child form that displays the grid.
I can work out how to generate the doubleclick event. In the Delphi 7 IDE I can get it to generate the following code for the child form:
procedure TForm4.NextGrid1DblClick(S
begin
end;
However I am not sure how to make the child form return control to the parent form.
If I just click an OK button on the child form I can grab the user's selection with this code:
if (Form4.showmodal = mrOK) then
result:= Form4.NextGrid1.SelectedRo
else
result:=-1;
How can I achieve a similar thing by double clicking.
In Visual C++ I could send a windows message with WM_CLOSE but I'm not sure how suitable this is in Delphi.
Sincerely,
Philip Truscott
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You might also want to make sure that you add the following line in the code that called the modal form so that you don't code in a memory leak.
Form4.Release;
P.s. I do hope that you are not actually using the automatically generated names for the components you are putting on forms or for the forms themselves. This is Not Good Codding Practice. ;-)
Form4.Release;
P.s. I do hope that you are not actually using the automatically generated names for the components you are putting on forms or for the forms themselves. This is Not Good Codding Practice. ;-)
ASKER