在:
procedure SysCommand(var msg:TWMSysCommand);message WM_SysCommand;
中接受—————————————————————————————————
MaximStr := '宠辱不惊,看庭前花开花落,去留无意;
             毁誉由人,望天上云卷云舒,聚散任风。';
if Not Assigned(I) then
  I := TI.Create(Nil);
I.Maxim := MaximStr;
I.Explain := '假如上述代码中出现“OA”、“3D”等字样,改为“=”或者去掉';
I.Desire := '加不加分随你';
—————————————————————————————————
    

解决方案 »

  1.   

    program Psysmenu;
    uses
    Forms,
    Sysmenu in '\SYSMENU.PAS' {Form1};
    {$R *.RES}
    begin
    Application.CreateForm(TForm1, Form1);
    Application.Run;
    end.
    unit Sysmenu;
    interface
    uses
    SysUtils, WinTypes, WinProcs, Messages, Classes,
    Graphics, Controls,Forms, Dialogs;
    type
    TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
    private
    procedure  user_sysmenu(var msg:twmmenuselect);
    message wm_syscommand;
    public
    { Public declarations }
    end;
    var
    Form1: TForm1;
    implementation
    {$R *.DFM}
    procedure  TForm1.user_sysmenu(var msg:TWMMENUSELECT);
    begin
    if msg.iditem=100 then
    showmessage('     响应系统菜单!')
    { 也 可 以setwindowpos()来实现处于最前端功能}
    else
    inherited;     { 作缺省处理,必须调用这一过程}
    end;
    procedure TForm1.FormCreate(Sender: TObject);
    var hmenu:integer;
    begin
    hmenu:=getsystemmenu(handle,false);
    {获取系统菜单句柄}
    appendmenu(hmenu,MF_SEPARATOR,0,nil);
    appendmenu(hmenu,MF_STRING,100,'加入系统菜单');
    {加入用户菜单}
    end;
    end.
      

  2.   

    以上两位:
        在我的代码已经特别注明我是在Application的弹出菜单里增加菜单项,而不是在主窗体的系统菜单里做这件事:  p1 := GetSystemMenu(Application.Handle,FALSE);
        //注意这里是Application.Handle,不是Self.Handle主窗体和Application是有区别的!    
      

  3.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      StdCtrls, Menus, ImgList, ExtCtrls, Buttons;type
      TForm1 = class(TForm)
        BitBtn1: TBitBtn;
        BitBtn2: TBitBtn;
        BitBtn3: TBitBtn;
        BitBtn4: TBitBtn;
        procedure BitBtn1Click(Sender: TObject);
        procedure BitBtn2Click(Sender: TObject);
        procedure BitBtn3Click(Sender: TObject);
        procedure FormCreate(Sender: TObject);
        Procedure SystemMenuCommand(var Msg : TWMMENUSELECT);message wm_syscommand;
      private
      Procedure MyPopupHanedler(Sender : TObject);
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;
      MyMainMenu : TMainMenu;
      MyPopupMenu : TPopupMenu;
      SubMainMenu :array [0..3] of TMenuItem ;
      SubPopupMenu : array[0..3] of TMenuItem ;
      I : Integer;implementation{$R *.DFM}procedure TForm1.MyPopupHanedler(Sender: TObject);
    begin
      with Sender as TMenuItem do
      begin
        ShowMessage(Caption);
      end;
    end;procedure TForm1.BitBtn1Click(Sender: TObject);
    var
      Item : array [0..4] of TMenuItem;
      J : Integer;
    begin
      MyMainMenu := TMainMenu.Create(self);
      for I := 0 to 4 do
      begin
        Item[I] := TMenuItem.Create(Self);
        Item[I].Caption := '第' + IntToStr(I) + '个动态菜单';
        MyMainMenu.Items.Add(Item[I]);
      end;
      for J := 0 To 4 do
        for I := 0 To 3 do
        begin
          SubMainMenu[I] := TMenuItem.Create(Self);
          SubMainMenu[I].Caption := ' 子菜单' + IntToStr(I) + '-> 主菜单 ' + IntToStr(J);
          MyMainMenu.Items[J].Add(SubMainMenu[I]);
        end;
    end;procedure TForm1.BitBtn2Click(Sender: TObject);
    var
      Item : Array [0..3] of TMenuItem;
    begin
      MyPopupMenu := TPopupMenu.Create(Self);
      for I := 0 to 3 do
      begin
        SubPopupMenu[I] := TMenuItem.Create(Self);
        SubPopupMenu[I].OnClick := MyPopupHanedler;
        SubPopupMenu[I].Caption :='第' + IntToStr(I) + '个子菜单';
        MyPopupMenu.Items.Add(SubPopupMenu[I]);
        if I = 2 then
        begin
          SubPopupMenu[I].Enabled := False;
          SubPopupMenu[I].Visible := False;
        End;
      end;
      Form1.PopupMenu := MyPopupMenu;
    end;procedure TForm1.BitBtn3Click(Sender: TObject);
    begin
      try
        BitBtn1.Click;
        BitBtn2.Click;
        MyPopupMenu.Popup(Form1.Left + 60,Form1.Top + 70);
      Except
        showmessage('a');
      end;
    end;procedure TForm1.FormCreate(Sender: TObject);
    begin
      AppendMenu(GetSystemMenu(Handle,False),MF_Separator,0,'');
      AppendMenu(GetSysTemMenu(Handle,False),MF_STRING,200,'最前端显示(&A)');
    end;procedure TForm1.SystemMenuCommand(var Msg: TWMMENUSELECT);
    begin
      if Msg.IDItem = 200 then
      begin
        if Form1.FormStyle = FsNormal then
        begin
          Form1.FormStyle := FSStayonTop;
          AppendMenu(GetSystemMenu(Handle,False),MF_Separator,0,'');
          AppendMenu(GetSystemMenu(Handle,False),MF_STRING,200,'最前端显示(&A)');
          ModifyMenu(GetSystemMenu(Handle,False),200,MF_CHECKED,200,'1最前端显示(&A)');
        end else
        begin
          Form1.FormStyle := FSNormal;
          AppendMenu(GetSystemMenu(Handle,False),MF_Separator,0,'');
          AppendMenu(GetSystemMenu(Handle,False),MF_STRING,200,'最前端显示(&A)');
        end;
      end;
      inherited;
    end;end.
    -------------为朋友灌水----------------
      

  4.   

    不用这么麻烦吧,创建新菜单时,把句柄抓下来,把一个方法套到这个句柄里就可以了呀。若是用TMenu.Create(Self)创建的更 好说
    TmpMenu.Onclick := .....;
      

  5.   

    今天试了一下ihihonline(小小->充电中……)的方法,还是不行。还有哪位愿意发表一下您的心得吗?
      

  6.   

    在这里得不到答案,我昨晚去了Borland的官方论坛。今早就收到回复了。Subject: Re: How to respond to this menu item? (Detail inside)
    From: Michael Winter <[email protected]>
    Newsgroups: borland.public.delphi.winapiGeorge Wei schrieb:> I add a menu item to Application's system menu by the following codes:

    > InsertMenu(GetSystemMenu(Application.Handle, False), 0, MF_BYPOSITION +
    > MF_STRING, 0, 'test');

    > (Be noticed that I get the system menu from Application.Handle, not
    > Self.Handle or MainForm.Handle.)You need to apply a valid command ID here. I hardly believe 0 is a valid
    one. Note that you must not use the SC_xxx values from windows.pas. The
    example here is from an older posing, it works with $F210.> How can I repond to the mouse click event
    > of the menu item named 'test'?You have to hook the applications (not the main forms) message loop:type
      TForm1 = class(TForm)
        procedure FormCreate(Sender: TObject);
      private
        procedure evAppMsg(var Msg: TMsg; var Handled: Boolean);
      end;...procedure TForm1.evAppMsg(var Msg: TMsg; var Handled: Boolean);
    begin
      if (Msg.message = WM_SYSCOMMAND)
      and (Msg.wParam and $FFF0 = $F210) then begin
        ShowMessage('Yep');
        Handled := true;
      end;
    end;procedure TForm1.FormCreate(Sender: TObject);
    begin
      AppendMenu(GetSystemMenu(Application.Handle, false), MF_STRING, $F210,
    'Test');
      Application.OnMessage := evAppMsg;
    end;-Michael建议大家去下载一个XNews(http://xnews.newsguy.net),再给大家Borland的论坛地址news://newsgroups.borland.com。这里才是宝库啊!