Programalama > DELPHI


Ort. 0
Puan ver:
...
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;



Yorumlar                 Yorum Yaz
Bu hazır kod'a ilk yorumu siz yapın!
KATEGORİLER
ASP - 240
ASP.NET - 24
C# - 75
C++ - 174
CGI - 8
DELPHI - 247
FLASH - 49
HTML - 536
PASCAL - 246
PERL - 11
PHP - 160
WML - 9
XML - 2
Copyright © 2002 - 2017 Hazır Kod - Tüm Hakları Saklıdır.
Siteden yararlanırken gizlilik ilkelerini okumanızı tavsiye ederiz.
hazirkod.com bir İSObil projesidir.