Windows with Delphi Windows API (94) Windows Filesystem (41) Windows Forms (69) Windows Graphics (38)
Exchange Links About this site Links to us 
|
Add your own entry in a window's system menu
This 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:
- define an id that identifies your new menu item. This should be a number larger than the regular SC_xxxx constants. (idMyFunc = $f200)
- add the menu item, for example during the FormCreate event. Use your new identifier idMyFunc.
- 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:
|