Reputation: 49
I'd like disable [X] close Button with VCL Style in DX Berlin.
Wy this code do not work wiht VCL Style?
EnableMenuItem(GetSystemMenu(Form3.Handle, LongBool(False)),SC_CLOSE, MF_BYCOMMAND or MF_GRAYED);
Upvotes: 5
Views: 6217
Reputation: 8386
When using VCL Styles by default style affect the appearance of fonts being used, client area of your form and also your forms border (this also include minimize, maximize and close buttons).
So from what I see you have two options:
StyleElements
property of your form to [seFont, seClient]
which means that style will only be applied to used fonts and client area of your form but the border area of your form would be unstyled and rendered by OS.Upvotes: 1
Reputation: 4751
If you set the action in the FormClose
event to caNone
, when you try to close the form (clicking on the red cross) nothing is going to happen. In 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.
Upvotes: 5