Delphi - Disable the [x] Close button in VCL styles

I would like to disable the [X] close button with VCL Style in DX Berlin.

Does this code not work with VCL Style?

EnableMenuItem(GetSystemMenu(Form3.Handle, LongBool(False)),SC_CLOSE, MF_BYCOMMAND or MF_GRAYED);
+4
source share
2 answers

If you set an action in an event FormCloseto caNone, nothing will happen when you try to close the form (by clicking on the red cross). This way you can disable the button.

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
 //You cannot type only caNone, otherwise you'll get a compiler error
 Action := TCloseAction.caNone;
end;

You can find caNone in System.UITypes; read the documentation for more information.

+3
source

VCL , , ( , ).

, , , :

  • StyleElements [seFont, seClient], , , .
  • , . , , , .
+1

Source: https://habr.com/ru/post/1654944/


All Articles