DelphiFAQ Home Search:

Add your own entry in a window's system menu

 

commentsThis article has not been rated yet. After reading, feel free to leave comments and rate it.

To add your own entry in a window's system menu, you need to follow these steps:


  1. define an id that identifies your new menu item. This should be a number larger than the regular SC_xxxx constants. (idMyFunc = $f200)
  2. add the menu item, for example during the FormCreate event. Use your new identifier idMyFunc.
  3. add some code in the WMSysCommand handler that checks for your menu event and put in your desired code


Use the following code as a basis:

type
  TForm1 = class(TForm);
  // ..
  private
    procedure WMSysCommand(var message: TWMSysCommand);
      message WM_SYSCOMMAND;
  // ..
  end;

implementation

const
  idMyFunc = $f200;

procedure TForm1.WMSysCommand(var message: TWMSysCommand);
begin
  inherited;
  if message.CmdType and $FFF0 = idMyFunc then
    ShowMessage('my new function');
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  AppendMenu(GetSystemMenu(Handle, False), MF_STRING, idMyFunc, 'Info');
end;

Comments:

 

 

Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option.
 
It seems that you are
from Los Angeles, US .

Info/ Feedback on this

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:
photo Add a picture:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity. The owner of this web site reserves the right to delete such material.