兄弟这样!!!!(转贴)
Unit OhYeah;
Interface
Uses
SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics,
Controls, Forms, Dialogs, Menus;
Type
TForm1 = Class (TForm)
Procedure FormCreate (Sender : TObject);
Private {Private declarations}
Public {Public declarations}
Procedure WinMsg (Var Msg : TMsg; Var Handled : Boolean);
Procedure DoWhatEever;
End;
Var
Form1 : TForm1;
Implementation
{$R *.DFM}
Const
ItemID = 99; // 这个ID number代表你的菜单项,可以是任何值。
Procedure Tform1.WinMsg (Var Msg : TMsg; Var Handled : Boolean);
Begin
If Msg.Message = WM_SYSCOMMAND Then
If Msg.WParam = ItemID Then DoWhatEver;
End;
Procedure TForm1.FormCreate (Sender : TObject);
Begin
Application.OnMessage := WinMsg;
AppendMenu (GetSystemMenu (Form1.Handle, False), MF_SEPARATOR,
0, '');
AppendMenu (GetSystemMenu (Form1.Handle, False), MF_BYPOSITION,
ItemID, '&My menu');
AppendMenu (GetSystemMenu (Application.Handle, False),
MF_SEPARATOR, 0, '');
AppendMenu (GetSystemMenu (Application.Handle, False),
MF_BYPOSITION, ItemID,'&My menu minimized');
End;
Procedure TForm1.DoWhatEver;
Begin
Exit; //你可以添加任何你想加的东西到这里
End;
End.