如何得到系统菜单的弹出消息?

解决方案 »

  1.   

    if Msg.message=WM_SYSCOMMAND then应该是这样吧?我有个在系统菜单添加菜单项的~~
      

  2.   

    //系统菜单消息响应
    procedure Tmain.RegisterMsg(var Msg:TMsg;var Handled:Boolean);
    begin
      if Msg.message=WM_SYSCOMMAND then
        begin
        if Msg.wParam=99 then
          ShellExecute(Handle,'open',PChar('http://boyzxd.myrice.com'),nil,nil,SW_SHOW)
        else if Msg.wParam=100 then about.ShowModal;
        end;
    end;
    ***************************************
    procedure Tfunc.AppendToSystemMenu(Form:TForm;Item:string;ItemID:word);
    var NormalSysMenu,MinimizedMenu:HMenu;
        AItem:Array[0..255] of Char;
        PItem:PChar;
    begin
      NormalSysMenu:=GetSystemMenu(Form.Handle,False);
      MinimizedMenu:=GetSystemMenu(Application.Handle,False);
      if Item='-' then
        begin
          AppendMenu(NormalSysMenu,MF_SEPARATOR,0,nil);
          AppendMenu(MinimizedMenu,MF_SEPARATOR,0,nil);
        end
      else
        begin
          PItem:=StrPCopy(@AItem,Item);
          AppendMenu(NormalSysMenu,MF_STRING,ItemID,PItem);
          AppendMenu(MinimizedMenu,MF_STRING,ItemID,PItem);
        end;
    end;
    *********************
    //添加系统菜单
      func.AppendToSystemMenu(main,'-',98);
      func.AppendToSystemMenu(main,'查看注册码(&R)',99);
      func.AppendToSystemMenu(main,'关于(&A)',100);
      Application.OnMessage:=RegisterMsg;
      

  3.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs;type
      TForm1 = class(TForm)
      private
        { Private declarations }
      public
        { Public declarations }
        procedure WMSYSCOMMAND(var Msg : TWMSysCommand); message WM_SYSCOMMAND;                        //非客户区重画消息
      end;var
      Form1: TForm1;implementation{$R *.dfm}{ TForm1 }procedure TForm1.WMSYSCOMMAND(var Msg: TWMSysCommand);
    begin
    if Msg.CmdType = 61587 then
        Showmessage('你调用了系统菜单');
      inherited;
    end;end.
      

  4.   

    用Tapplicationevent截获相同的消息,肯定没问题
      

  5.   

    报错信息是分类的!
    不关是系统的,还是DBS的!
    如果用那么多的代码去做,还不如TRY呢!TRY
     EXCEPT
      ON 错误类 do
      begin
      end;
    ……
      

  6.   

    请拦截Application窗口的WM_INITMENU消息即可。
    http://kingron.myetang.com/document/appsysmenu.htt
      

  7.   

    to Kingron(单身走我路……) 我试了你的代码,可是弹出message(showmessage('ok'))
    但是用form1.popupmenu.popu(100,200)就完全没有反映了,why?
      

  8.   

    Kingron(单身走我路……) 
    的方法如果在弹出菜单是行不通的。
    我以前也问过一个问题,不过已完满解决。
    联系我吧。[email protected]
    要看效果的看下面DEMOhttp://bbs.soft163.com/uploadImages/2002772034334754.zip
      

  9.   

    http://www.csdn.net/expert/topic/1037/1037987.xml?temp=.9036066