如何实现Toolbar不够长的时候右边自动出来一个下拉按钮,并把隐藏的按钮项目放到菜单里面?我想可以用放到toolbar里的speedbutton来做那个下拉按钮并配合popupmenu来实现,但是遇到xpmenu等修改界面控件的时候就会出现toolbutton和speedbutton风格的不一致。我想问:1。怎样改变toolbar中某一个toolbutton的大小,并且不影响其他toolbutton。因为按照我上面的想法,用地道的toolbutton要比speedbutton好得多。2。如果不行,那么请推荐给我一个能够实现题目功能的控件,要求:
(1)能够和xpmenu之类的界面修改控件很好的配合,这样才能保证界面风格的一致性。
(2)最好在商业应用中能够免费。
(3)我知道D6的VCL自带的TActionToolbar,但是好像不能和xpmenu配合,并且界面生硬,最好不要告诉我是这个。
/////////////////////////////////////我更希望能够得到第一个问题的答案,谢谢!

解决方案 »

  1.   

    好像这杨的功能就是windows标准组件能够提供的。
      

  2.   

    帮你up先,应该是任务栏上的那种模式吧,classname是toolbarwindows32,看来要同coolbar结合起来。
      

  3.   

    我看了vcl源代码,里面改变ttoolbutton大小的函数是这个:
    procedure TToolBar.CreateButtons(NewWidth, NewHeight: Integer);  function ToolButtonVisible: Boolean;
      var
        I: Integer;
        Control: TControl;
      begin
        for I := 0 to FButtons.Count - 1 do
        begin
          Control := TControl(FButtons[I]);
          if (Control is TToolButton) and ((csDesigning in ComponentState) or
            Control.Visible) and not (TToolButton(Control).Style in
            [tbsSeparator, tbsDivider]) then
          begin
            Result := True;
            Exit;
          end;
        end;
        Result := False;
      end;var
      ImageWidth, ImageHeight: Integer;
      I: Integer;
    begin
      BeginUpdate;
      try
        HandleNeeded;
        Perform(TB_BUTTONSTRUCTSIZE, SizeOf(TTBButton), 0);
        Perform(TB_SETINDENT, FIndent, 0);
        if FImages <> nil then
        begin
          ImageWidth := FImages.Width;
          ImageHeight := FImages.Height;
        end
        else if FDisabledImages <> nil then
        begin
          ImageWidth := FDisabledImages.Width;
          ImageHeight := FDisabledImages.Height;
        end
        else if FHotImages <> nil then
        begin
          ImageWidth := FHotImages.Width;
          ImageHeight := FHotImages.Height;
        end
        else
        begin
          ImageWidth := 0;
          ImageHeight := 0;
        end;//注意这句:    Perform(TB_SETBITMAPSIZE, 0, MakeLParam(ImageWidth, ImageHeight));//<---------//我看了delphi里面有关TB_SETBITMAPSIZE的帮助,似乎windows并不支持toolbar的toolbuttons有不同大小。那么第一个问题无答案,不知道这样的判断是不是太早了    { Adjust the working height if there is a visible TToolButton whose caption
          height is automatically added by the common control. }
    //    if ShowCaptions and ToolButtonVisible then Dec(NewHeight, FHeightMargin);
        { Prevent toolbar from setting default button size }
        if NewWidth <= 0 then NewWidth := 1;
        if NewHeight <= 0 then NewHeight := 1;
        Perform(TB_SETBUTTONSIZE, 0, MakeLParam(NewWidth, NewHeight));
        FButtonWidth := NewWidth;
        FButtonHeight := NewHeight;
      finally
        EndUpdate;
      end;
      { Retrieve current button sizes }
      for I := 0 to InternalButtonCount - 1 do Perform(TB_DELETEBUTTON, 0, 0);
      UpdateButtons;
      UpdateImages;
      GetButtonSize(FButtonWidth, FButtonHeight);
    end;
      

  4.   

    http://www.huaxue.net/download/download.asp?id=114&url=1
      

  5.   

    要写一个专门计算的函数,
    再出现
    所有button的宽度大于窗体或父控件的宽度的时候
    你应该把超出的个数计算出来,然后添加一个双箭头的button,
    并且是下拉式的,然后再往里面添加超出的button.
    说得这么简单其实实现起来非常麻烦.建议下载toolbar2000控件
    他的那个计算函数恐怖689行。大概的思路应该是这样
      

  6.   

    请问哪里有toolbar2000下载?
    是否免费?
    有无源码?
      

  7.   

    vcl的toolbutton好像有问题,visible=false有时候不好用,请问这怎么回事?
      

  8.   

    vcl的toolbutton好像有问题,visible=false有时候不好用,请问这怎么回事?
      

  9.   

    DevExpress控件可以完成你的要求
      

  10.   

    我也遇到相同的问题!
    做界面,出现快捷菜单(就是ToolBar)折行的问题!
    客户要求像IE那样在显示不下的情况下,出现下拉当然TB2k可实现差不多的效果,可是使用起来的机制好像有些不同!
    因为我的ToolBarButton是动态创建的,而TB2k的相应方法不一样!
    要是更换控件的话,我的单元要有大的改动!唉~烦恼中!
      

  11.   

    windows桌面快捷启动工具栏的图标可以实现这样的折行和隐藏功能,ms的很多东西比如ie,,office,vs.net都能够有这样的功能。我想是不是windows本身能够提供的呢?我记得以前在vc板看到类似的贴子,似乎答案是createtoolbarex,但是不知道具体怎么用,不知道这个思路如何,请大家帮着想想啊。。
      

  12.   

    CreateToolbarEx?
    :(
    见过没用过!
    去找找这方面的资料去~
      

  13.   

    摘自msdn:CreateToolbarEx
    Creates a toolbar window and adds the specified buttons to the toolbar. Note: This function is obsolete. Use CreateWindow instead. ???????????????????????????HWND CreateToolbarEx(
        HWND hwnd,
        DWORD ws,
        UINT wID, 
        int nBitmaps, 
        HINSTANCE hBMInst, 
        UINT_PTR wBMID, 
        LPCTBBUTTON lpButtons, 
        int iNumButtons, 
        int dxButton, 
        int dyButton, 
        int dxBitmap, 
        int dyBitmap, 
        UINT uStructSize
    );Parameters
    hwnd 
    Handle to the parent window for the toolbar. 
    ws 
    Window styles for the toolbar. The WS_CHILD style is included by default. This parameter can also include a combination of styles as discussed in Toolbar Control and Button Styles. 
    wID 
    Control identifier for the toolbar. 
    nBitmaps 
    Number of button images contained in the bitmap specified by hBMInst and wBMID. 
    hBMInst 
    Module instance with the executable file that contains the bitmap resource. 
    wBMID 
    Resource identifier for the bitmap resource. If hBMInst is NULL, this parameter must be a valid bitmap handle. 
    lpButtons 
    Address of an array of TBBUTTON structures that contain information about the buttons to add to the toolbar. 
    iNumButtons 
    Number of buttons to add to the toolbar. 
    dxButton 
    Width, in pixels, of the buttons to add to the toolbar. 
    dyButton 
    Height, in pixels, of the buttons to add to the toolbar. 
    dxBitmap 
    Width, in pixels, of the button images to add to the buttons in the toolbar. 
    dyBitmap 
    Height, in pixels, of the button images to add to the buttons in the toolbar. 
    uStructSize 
    Size of a TBBUTTON structure. 
    Return Values
    Returns the window handle to the toolbar if successful, or NULL otherwise. To retrieve extended error information, call GetLastError. Res
    Windows 95: The system can support a maximum of 16,364 window handles. Requirements 
      Windows NT/2000: Requires Windows NT 3.51 or later 
      Windows 95/98/Me: Requires Windows 95 or later 
      Header: Declared in commctrl.h. 
      Import Library: comctl32.lib.