大家都知道想东方影都和豪杰解霸这种有名的软件有一个任务栏图表,那里有右键属性,我现在要问的就是,在一个界面最小化后图表放在任务栏上,怎样做它的右键弹出菜单?
急急!!
做好了再加,最高100分!!

解决方案 »

  1.   

    找一下做托盘方面的资料看看不就得了,很easy的。网上多的是
      

  2.   

    RZ中有一个控件TTrayIcon.一切都解决了,省事.
      

  3.   

    TTrayIcon中有什么特殊的属性需要设置吗?
      

  4.   

    procedure TForm1.FormCreate(Sender: TObject);
    var
      hmenu: THandle;
    begin
      hmenu := GetSystemMenu(Application.handle, false);
      AppendMenu(hmenu, MF_SEPARATOR, 0, nil);
      AppendMenu(hmenu, MF_STRING, 4001, 'this is my menu');
    end;
      

  5.   

    直接使用托盘控件,可以指定在任务栏图标上右击或左键的PopupMenu下面是托盘的原代码unit TrayIcon;
    interfaceuses
      SysUtils, Windows, Messages, Classes, Graphics, Controls, ShellAPI,
      Forms;const WM_TOOLTRAYICON = WM_USER+1;
          WM_RESETTOOLTIP = WM_USER+2;type
      TTrayIcon = class(TComponent)
      private
      { Field Variables }
        IconData: TNOTIFYICONDATA;
        fIcon : TIcon;
        fToolTip : String;
        fWindowHandle : HWND;
        fActive : boolean;
        fShowDesigning : Boolean;
      { Events }    fOnClick     : TNotifyEvent;
        fOnDblClick  : TNotifyEvent;
        fOnRightClick : TMouseEvent;    function AddIcon : boolean;
        function ModifyIcon : boolean;
        function DeleteIcon : boolean;    procedure SetActive(Value : boolean);
        procedure SetShowDesigning(Value : boolean);
        procedure SetIcon(Value : TIcon);
        procedure SetToolTip(Value : String);
        procedure WndProc(var msg : TMessage);    procedure FillDataStructure;
      protected
        constructor create(aOwner : TComponent); override;
        destructor destroy; override;
      public
      published
        property Active : boolean read fActive write SetActive;
        property ShowDesigning : boolean read fShowDesigning write SetShowDesigning;
        property Icon : TIcon read fIcon write SetIcon;
        property ToolTip : string read fTooltip write SetToolTip;    property OnClick     : TNotifyEvent read FOnClick write FOnClick;
        property OnDblClick  : TNotifyEvent read FOnDblClick write FOnDblClick;
        property OnRightClick : TMouseEvent  read FOnRightClick write FonRightClick;
      end;procedure Register;implementation//{$R TrayIcon.res}procedure TTrayIcon.SetActive(Value : boolean);
    begin
       if value <> fActive then begin
         fActive := Value;
         if not (csdesigning in ComponentState) then begin
            if Value then begin
               AddIcon;
            end else begin
               DeleteIcon;
            end;
         end;
      end;
    end;procedure TTrayIcon.SetShowDesigning(Value : boolean);
    begin
      if csdesigning in ComponentState then begin
         if value <> fShowDesigning then begin
            fShowDesigning := Value;
            if Value then begin
               AddIcon;
            end else begin
               DeleteIcon;
            end;
         end;
      end;
    end;procedure TTrayIcon.SetIcon(Value : Ticon);
    begin
      if Value <> fIcon then
        begin
          fIcon.Assign(value);
          ModifyIcon;
        end;
    end;procedure TTrayIcon.SetToolTip(Value : string);
    begin   // This routine ALWAYS re-sets the field value and re-loads the
       // icon.  This is so the ToolTip can be set blank when the component
       // is first loaded.  If this is changed, the icon will be blank on
       // the tray when no ToolTip is specified.   if length( Value ) > 62 then
          Value := copy(Value,1,62);
       fToolTip := value;
       ModifyIcon;
    end;constructor TTrayIcon.Create(aOwner : TComponent);
    begin
      inherited create(aOwner);
      FWindowHandle := AllocateHWnd( WndProc );
      FIcon := TIcon.Create;
    //  SetWindowLong(Application.Handle, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
    end;destructor TTrayIcon.destroy;
    begin
      if (not (csDesigning in ComponentState) and fActive)
         or ((csDesigning in ComponentState) and fShowDesigning) then
            DeleteIcon;  FIcon.Free;
      DeAllocateHWnd( FWindowHandle );
      inherited destroy;
    end;procedure TTrayIcon.FillDataStructure;
    begin
      with IconData do
      begin
         cbSize := sizeof(TNOTIFYICONDATA);
         wnd := FWindowHandle;
         uID := 0; // is not passed in with message so make it 0
         uFlags := NIF_MESSAGE + NIF_ICON + NIF_TIP;
         hIcon := fIcon.Handle;
         StrPCopy(szTip,fToolTip);
         uCallbackMessage := WM_TOOLTRAYICON;
      end;
    end;function TTrayIcon.AddIcon : boolean;
    begin
       FillDataStructure;
       result := Shell_NotifyIcon(NIM_ADD,@IconData);   // For some reason, if there is no tool tip set up, then the icon
       // doesn't display.  This fixes that.   if fToolTip = '' then
          PostMessage( fWindowHandle, WM_RESETTOOLTIP,0,0 );
    end;function TTrayIcon.ModifyIcon : boolean;
    begin
       FillDataStructure;
       if fActive then
          result := Shell_NotifyIcon(NIM_MODIFY,@IconData)
       else
          result := True;
    end;function TTrayIcon.DeleteIcon : boolean;
    begin
       result := Shell_NotifyIcon(NIM_DELETE,@IconData);
    end;procedure TTrayIcon.WndProc(var msg : TMessage);
    var MouseCo: TPoint;
    begin
       with msg do
         if (msg = WM_RESETTOOLTIP) then
            SetToolTip( fToolTip )
         else if (msg = WM_TOOLTRAYICON) then
         begin
           case lParam of
             WM_LBUTTONDBLCLK: if assigned (FOnDblClick) then FOnDblClick
                                                              (self);
             WM_LBUTTONUP    : if assigned(FOnClick)then FOnClick(self);
             WM_RBUTTONUP    : if assigned (FOnRightClick)then
                               begin
                                  GetCursorPos(MouseCo);
                                  FOnRightClick(self,mbRight,[],
                                                MouseCo.x, MouseCo.y);
                               end;
           end;
         end
         else // Handle all messages with the default handler
            Result := DefWindowProc(FWindowHandle, Msg, wParam, lParam);
    end;procedure Register;
    begin
      RegisterComponents('Samples', [TTrayIcon]);
    end;end.
      

  6.   

    为什么我用这段代码实现不了?
    不过,我看过了一本书《深入浅出 Delphi6.0》,搞定了。