Forum > LCL

BitBtn bkClose closes window even though ModalResult is mrNone. Bug or feature?

<< < (3/3)

ASerge:

--- Quote from: Aidex on November 12, 2017, 11:27:44 am ---Hello!
I hoped mrNone would prevent automatically closing the form, but the window closes before I can handle the button's OnClick event.
As I understood mrNone, it shouldn't close a form.

--- End quote ---
Widely known, but not documented feature. When Kind = bkClose, always closed the parent form. If you like the "Close" picture, put the style in bkCustom, in this case the special behavior disappears, but the picture remains.

FTurtle:

--- Quote from: ASerge on November 12, 2017, 01:43:44 pm ---Widely known, but not documented feature. When Kind = bkClose, always closed the parent form. If you like the "Close" picture, put the style in bkCustom, in this case the special behavior disappears, but the picture remains.

--- End quote ---

Code:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.FormCreate(Sender: TObject);begin  BitBtn1.Kind:=bkClose;  BitBtn1.Kind:=bkCustom;  BitBtn1.ModalResult:=mrNone;end; 

AgriMensor:
I can't find where the bkAbort and other bk constants are defined, so the unit won't compile when I rry to set .Kind programmatically. Can you please point me to where they are? Thx!

wp:

--- Quote from: AgriMensor on May 21, 2024, 05:45:32 pm ---I can't find where the bkAbort and other bk constants are defined, so the unit won't compile when I rry to set .Kind programmatically. Can you please point me to where they are? Thx!

--- End quote ---
Unit "buttons" (but this should be added to "uses" automatically when you drop a TBitBtn on the form).

AgriMensor:

--- Quote from: wp on May 21, 2024, 07:29:35 pm ---
--- Quote from: AgriMensor on May 21, 2024, 05:45:32 pm ---I can't find where the bkAbort and other bk constants are defined, so the unit won't compile when I rry to set .Kind programmatically. Can you please point me to where they are? Thx!

--- End quote ---
Unit "buttons" (but this should be added to "uses" automatically when you drop a TBitBtn on the form).

--- End quote ---
Great, wp, thanks very much! It now works fine. It wasn't automatically dropped into the Uses section. Either that, or I've inadvertently deleted it, but I don't think so!

Navigation

[0] Message Index

[*] Previous page

Go to full version