www.bcgsoft.com看BCGCtrlBar的工具栏、菜单,都具有这个功能。
有源代码。

解决方案 »

  1.   

    If the combined width of the bands on a strip exceeds the width of the window, the rebar control will adjust their widths as needed. Some of the tools might be covered by the adjacent band.Version 5.80 of the common controls provides a way to make tools that have been covered by another band accessible to the user. If you set the RBBS_USECHEVRON flag in the fStyle member of the band's REBARBANDINFO structure, a chevron will be displayed for toolbars that have been covered. When a user clicks the chevron, a menu is displayed that allows him or her to use the hidden tools. The following illustration from Internet Explorer 5 shows the menu that is displayed when part of the standard toolbar is covered by the address bar. 
    Since each band contains a control, you can provide additional flexibility through the control's API. For example, you can implement toolbar customization to allow the user to add, move, or delete buttons on a toolbar.Implementing the Rebar Control
    Most of the features of the Internet Explorer toolbar are actually implemented in the individual bands. The implementation of the rebar control itself is relatively straightforward:Create the rebar control with CreateWindowEx. Set dwExStyle to WS_EX_TOOLWINDOW and lpClassName to REBARCLASSNAME. Internet Explorer uses the following window styles:RBS_BANDBORDERS 
    RBS_DBLCLKTOGGLE 
    RBS_REGISTERDROP 
    RBS_VARHEIGHT 
    CCS_NODIVIDER 
    CCS_NOPARENTALIGN 
    WS_BORDER 
    WS_CHILD 
    WS_CLIPCHILDREN 
    WS_CLIPSIBLINGS 
    WS_VISIBLE 
    Set the other parameters as appropriate for your application.Create a control with CreateWindowEx or a specialized control creation function such as CreateToolbarEx. 
    Initialize a band for the control by filling in the members of REBARBANDINFO. Include the RBBS_USECHEVRON style with the fStyle member to enable chevrons. 
    Add the band to the rebar control with an RB_INSERTBAND message. 
    Repeat steps 2-4 for the remaining bands. 
    Implement handlers for the rebar notifications. In particular, you will need to handle RBN_CHEVRONPUSHED to display a dropdown menu when a chevron is clicked. For further information, see Handling Chevrons. 
    The grippers are included by default. To omit the gripper for a band, set the RBBS_NOGRIPPER flag in the fStyle member of the band's REBARBANDINFO structure. For further information on implementing rebar controls, see Rebar Controls. Handling Chevrons
    When a user clicks a chevron, the rebar control sends your application an RBN_CHEVRONPUSHED notification. The NMREBARCHEVRON structure that is passed with the notification contains the band's identifier and a RECT structure with the rectangle occupied by the chevron. Your handler must determine which buttons are hidden and display the associated commands on a pop-up menu.The following procedure outlines how to handle an RBN_CHEVRONPUSHED notification:Get the current bounding rectangle for the selected band by sending the rebar control an RB_GETRECT message. 
    Get the total number of buttons by sending the band's toolbar control a TB_BUTTONCOUNT message. 
    Starting from the leftmost button, get the button's bounding rectangle by sending the toolbar control a TB_GETITEMRECT message. 
    Pass the band and button rectangles to IntersectRect. This function will return a RECT structure that corresponds to the visible portion of the button. 
    Pass the button rectangle and the rectangle for the visible portion of the button to EqualRect. 
    If EqualRect returns TRUE, the entire button is visible. Repeat steps 3-5 for the next button on the toolbar. If EqualRect returns FALSE, the button is at least partially hidden and all remaining buttons will be completely hidden. Continue to the next step. 
    Create a pop-up menu with items for each of the hidden buttons. 
    Display the pop-up menu with TrackPopupMenu. Use the chevron rectangle passed with the RBN_CHEVRONPUSHED notification to position the menu. The menu should be immediately below the chevron, with the left edges aligned. 
    Handle the menu commands. 
      

  2.   

    see Creating an Internet Explorer-style Toolbar in Common Controls How Tos