TBitBTn with Kind=bkClose and ModalResult=mrClose does not set ParentForm's ModalResult to mrClose
Original Reporter info from Mantis: Bart @flyingsheep
-
Reporter name: Bart Broersma
Original Reporter info from Mantis: Bart @flyingsheep
- Reporter name: Bart Broersma
Description:
A TBitBtn with Kind set to bkClose and ModalResult set to mrClose (or anything else that differs from mrNone) will not set ModalResult for it's parentform when clicked.
Steps to reproduce:
On an empty form drop a TBitBtn.
In OI set Kind=bkClose
in OI set ModalResult=mrClose
Do a ShowModal of this form
Click the BitBtn
ModalResult will be mrCancel
This behaviour is inconsistent with modern Delphi's (at least with Delphi XE)
As a consequence of this behaviour, MessageDlg (our own one in TPromptDialog) with mbClose in Buttons will never return mrClose (see #21801 (closed))
Additional information:
This is the piece of code that is resposable for this behaviour:
in lcl/include/bitbtn.inc
procedure TCustomBitBtn.Click;
var
Form : TCustomForm;
begin
if FKind = bkClose then begin
Form := GetParentForm(Self);
if Form <> nil then begin
Form.Close;
exit;
end;
end;
inherited Click;
end;
inherited click calls (in lcl/include/buttons.inc)
procedure TCustomButton.Click;
var
Form : TCustomForm;
Begin
if ModalResult <> mrNone
then begin
Form := GetParentForm(Self);
if Form <> nil then Form.ModalResult := ModalResult;
end;
inherited Click;
end;
I think this code is an inheritence of "older" Delphi's that did not have mrClose as a predefined valid ModalResult.
Now we (and Delphi) have mrClose defined, it makes no sense that it cannnot be returned by a TBitBtn.
Mantis conversion info:
- Mantis ID: 21844
- OS: Window
- OS Build: Win7
- Build: r36898
- Platform: i386
- Version: 1.1 (SVN)
- Fixed in revision: r37064 (#24cd5e93)
- Target version: 1.0.0