Set a new system menu
Add this line in the private part of the form :
Procedure SetFormSystemMenu ( AFormHandle : HWnd ) ;
And
the procedure in the implementation :
Procedure
TForm1.SetFormSystemMenu ( AFormHandle : HWnd ) ;
Const
STR_CLOSE = '&CLOSE' ;
STR_MAXIMIZE = 'MA&IMIZE' ;
STR_MINIMIZE = 'MI&NIMIZE' ;
STR_SIZE = '&SIZE' ;
STR_MOVE = '&MOVE' ;
STR_RESTORE = '&RESTORE' ;
Var
SystemMenu : HMenu ;
MyMenuItemInfo : TMenuItemInfo ;
Begin
SystemMenu := GetSystemMenu (
AFormHandle , FALSE ) ;
FillChar ( MyMenuItemInfo ,
SizeOf ( TMenuItemInfo ) , #0 ) ;
MyMenuItemInfo.cbSize := SizeOf (
TMenuItemInfo ) ;
MyMenuItemInfo.fMask := MIIM_TYPE
Or MIIM_ID Or MIIM_STATE ;
MyMenuItemInfo.fType :=
MFT_STRING ;
MyMenuItemInfo.wId := SC_CLOSE ;
MyMenuItemInfo.dwTypeData :=
STR_CLOSE ;
MyMenuItemInfo.cch := Length (
STR_CLOSE ) ;
SetMenuItemInfo ( SystemMenu ,
SC_CLOSE ,
FALSE ,
MyMenuItemInfo
) ;
MyMenuItemInfo.wId := SC_MAXIMIZE
;
MyMenuItemInfo.dwTypeData :=
STR_MAXIMIZE ;
MyMenuItemInfo.cch := Length (
STR_MAXIMIZE ) ;
SetMenuItemInfo ( SystemMenu ,
SC_MAXIMIZE ,
FALSE ,
MyMenuItemInfo
) ;
MyMenuItemInfo.wId := SC_MINIMIZE
;
MyMenuItemInfo.dwTypeData :=
STR_MINIMIZE ;
MyMenuItemInfo.cch := Length (
STR_MINIMIZE ) ;
SetMenuItemInfo ( SystemMenu ,
SC_MINIMIZE ,
FALSE ,
MyMenuItemInfo
) ;
MyMenuItemInfo.wId := SC_SIZE ;
MyMenuItemInfo.dwTypeData :=
STR_SIZE ;
MyMenuItemInfo.cch := Length (
STR_SIZE ) ;
SetMenuItemInfo ( SystemMenu ,
SC_SIZE ,
FALSE ,
MyMenuItemInfo
) ;
MyMenuItemInfo.wId := SC_MOVE ;
MyMenuItemInfo.dwTypeData :=
STR_MOVE ;
MyMenuItemInfo.cch := Length (
STR_MOVE ) ;
SetMenuItemInfo ( SystemMenu ,
SC_MOVE ,
FALSE ,
MyMenuItemInfo
) ;
MyMenuItemInfo.wId := SC_RESTORE
;
MyMenuItemInfo.dwTypeData :=
STR_RESTORE ;
MyMenuItemInfo.cch := Length (
STR_RESTORE ) ;
SetMenuItemInfo ( SystemMenu ,
SC_RESTORE ,
FALSE ,
MyMenuItemInfo
) ;
End ;
Example :
SetFormSystemMenu ( Handle ) ;