getsystemmenu得到的并不是系统菜单的句柄,而是系统菜单的副本的句柄,即得到另一个菜单
的句柄,只不过这个菜单是用系统菜单初始化的,这时菜单项点击发出的已不是Wm_syscommand;
而是wm_command,你所要做的就是为这个消息加代码了。

解决方案 »

  1.   

    type
      ArrSMId:Array [0..4] of Integer=(100,101,102,103,104);   //自定义系统菜单ID
      ArrItemName:Array[0..3] of String=('正常显示','装饰滚动条',
                                        '装饰边框','装饰滚动条和边框');
    ........
    var
      i:integer;
    begin
      for i:=high(ArrItemname) downto 0 do
        InsertMenu(GetSystemMenu(handle,false),
                  MF_STRING,MF_BYPOSITION,ArrSmId[i],
                  Pchar(ArrItemName[i]));.....
    procedure TForm1.MySysMenuClick(var Msg:TWMSysCommand);
    begin
      inherited;
      { 拦截自定义系统菜单ID }
      if (Integer(Msg.CmdType)>99) and (Integer(Msg.CmdType)<105) then
      begin
        Case Integer(Msg.CmdType) of
          100,
          101,
          102,
          103 :SetBmpViewStyle(Integer(msg.CmdType)-100);
          104 :ShowAbout('About: '+fCaption,nil);
        end;
      end;
    end;
      

  2.   

    to net_z():我不是要增加菜单项,只是要实现系统菜单功能
    to OysterLQD(沉默者):怎么加代码?怎么识别是选了哪个菜单项?有源代吗吗?
      

  3.   

      popmenu:hmenu;
      popids:array of integer;
      menucount:integer;procedure TForm1.FormCreate(Sender: TObject);
    var
    icount:integer;
    begin
    popmenu:=getsystemmenu(self.Handle,false);
    menucount:= getmenuitemcount(popmenu) ;
    setlength(popids,menucount);
    for icount:=0 to menucount do
    begin
    popids[icount]:=getmenuitemid(popmenu,icount);
    end;
    end;procedure tform1.wmcommand(var msg:twmcommand);
    var
    icount:integer;
    begin
    inherited;
    if msg.ItemID=popids[0] then
    showmessage('u press the first item');
    end;procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);begin
    if button=mbright then
    trackpopupmenuex(popmenu,0,x,y,self.Handle,nil);
    end;见笑了
      

  4.   

    I See
    Thanks
    太繁了一点
    不过没有办法了