...
const
SC_MyMenuItem1 = WM_USER + 1;
...
procedure TForm1.btnAddClick(Sender: TObject);
const
sMyMenuCaption1='My n&ew system menu item';
var
SysMenu : HMenu;
begin
{Get system menu}
SysMenu := GetSystemMenu(Handle, FALSE);
{Add a seperator bar to main form-form1}
AppendMenu(SysMenu, MF_SEPARATOR, 0, '');
{add our menu}
AppendMenu(SysMenu, MF_STRING,
SC_MyMenuItem1, sMyMenuCaption1);
end;




...
private
procedure WMSysCommand(var Msg: TWMSysCommand);
message WM_SYSCOMMAND;
...
procedure TForm1.WMSysCommand(var Msg:TWMSysCommand);
begin
if Msg.CmdType = SC_MyMenuItem1 then begin
{some code to handle my menu item:}
ShowMessage('My system menu 1 clicked!');
end else
inherited;
end;




procedure TForm1.btnDeleteClick(Sender: TObject);
const
MnuCommand = SC_MOVE;
var
SysMenu : HMenu;
begin
SysMenu := GetSystemMenu(Handle, FALSE);

DeleteMenu(SysMenu, MnuCommand, MF_BYCOMMAND);
end;





procedure TForm1.btnChangeClick(Sender: TObject);
const
strCLOSE = '&Close This Window';
var
SysMenu : HMenu;
MenuItemInfo : TMenuItemInfo;
begin
SysMenu := GetSystemMenu(Handle, FALSE);

FillChar(MenuItemInfo,SizeOf(TMenuItemInfo), #0);
MenuItemInfo.cbSize := SizeOf(TMenuItemInfo);
MenuItemInfo.fMask := MIIM_TYPE or
MIIM_ID or MIIM_STATE;
MenuItemInfo.fType := MFT_STRING;

MenuItemInfo.wId := SC_CLOSE;
MenuItemInfo.dwTypeData := strCLOSE;
MenuItemInfo.cch := Length(strCLOSE);

SetMenuItemInfo(SysMenu, SC_CLOSE,
FALSE, MenuItemInfo);
end;

Beğeniler: 0
Favoriler: 0
İzlenmeler: 597
favori
like
share
systemdesk Tarih: 09.03.2006 17:33
teşekkürler