我经常看到一些程序的系统菜单中有自己的菜单(就是关闭,最大化,最小化,还原之类的菜单里),他是怎么加进去的?

解决方案 »

  1.   

    SysMenu:HMenu;  WM_ABOUT=WM_USER+20;      //******************************************
          //add about menu item
          SysMenu:=GetSystemMenu(Application.Handle,False);
          AppendMenu(SysMenu,MF_SEPARATOR,0,nil);
          AppendMenu(SysMenu,MF_STRING,WM_ABOUT,pchar('About...'));
          SysMenu:=GetSystemMenu(Handle,False);
          AppendMenu(SysMenu,MF_SEPARATOR,0,nil);
          AppendMenu(SysMenu,MF_STRING,WM_ABOUT,pchar('About...'));
          Application.OnMessage:=OnAppMessage;
    procedure OnAppMessage(var Msg : TMsg ; Var Handled : Boolean);procedure TFormMain.OnAppMessage(var Msg : TMsg ; Var Handled : Boolean);
    //about menuitem in system menu
    //2002.09.01
    begin
      if Msg.message=WM_SYSCOMMAND then begin
        if Msg.wParam=WM_ABOUT then begin
          try
            FormAbout:=TFormAbout.Create(self);
            FormAbout.ShowModal;
          finally
            FormAbout.Free;
          end;
        end;
      end;
    end;
      

  2.   

    procedure TForm1.FormCreate(Sender: TObject); 
    begin 
    AppendMenu(GetSystemMenu(Handle, False), MF_SEPARATOR, 0, ''); 
    AppendMenu(GetSystemMenu(Handle, False), MF_STRING, 1111, '&About...'); 
    AppendMenu(GetSystemMenu(Application.Handle, False), MF_SEPARATOR, 0, ''); 
    AppendMenu(GetSystemMenu(Application.Handle, False), MF_STRING, 1111, '&About...'); 
    Application.OnMessage := AppMessage; 
    end; procedure TForm1.AppMessage(var Msg: TMsg; var Handled: Boolean); 
    begin 
    if (Msg.Message = WM_SYSCOMMAND) and (Msg.WParam = 1111) then 
    begin 
    with TFormAbout.Create(Self) do 
    try 
    Handled := True; 
    ShowModal; 
    finally 
    Release; 
    end; 
    end; 
    end;