早说明白阿。靠。
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
procedure OnAppMessage(var Msg: TMsg; var Handled: Boolean);
end;
var
Form1: TForm1;
implementation
const
SC_MyMenuItem = WM_USER + 1;
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
// Assign the application's OnMessage event to my own
// procedure so I can check for the hidden window's WM_SYSCOMMAND
// message.
Application.OnMessage := OnAppMessage;
AppendMenu(GetSystemMenu(Application.Handle, FALSE), MF_SEPARATOR, 0, '');
AppendMenu(GetSystemMenu(Application.Handle, FALSE),
MF_STRING,
SC_MyMenuItem,
'My Menu Item');
end;
procedure TForm1.OnAppMessage(var Msg: TMsg; var Handled: Boolean);
begin
// Check to see if the message is a system command
// and the message's wParam is SC_MyMenuItem
if (Msg.message = WM_SYSCOMMAND) and (Msg.wParam = SC_MyMenuItem) then
begin
ShowMessage('Got the message');
Handled := True;
end;
end;