COMMON CONTROLS 5.0 中TOOLBAR的button没有DROPDOWN style属性。有什么办法没有?

解决方案 »

  1.   

    发送TB_SETBUTTONINFO消息,给按键加上TBSTYLE_DROPDOWN风格MSDN:
    TB_SETBUTTONINFO
    TB_SETBUTTONINFO
        wParam = (WPARAM)(INT) iID;
        lParam = (LPARAM)(LPTBBUTTONINFO) lptbbi;Sets the information for an existing button in a toolbar. Returns nonzero if successful, or zero otherwise. 
    iID 
    Button identifier. 
    lptbbi 
    Address of a TBBUTTONINFO structure that contains the new button information. The cbSize and dwMask members of this structure must be filled in prior to sending this message. TBBUTTONINFO
    typedef struct {
        UINT cbSize;
        DWORD dwMask;
        int idCommand;
        int iImage;
        BYTE fsState;
        BYTE fsStyle;
        WORD cx;
        DWORD lParam;
        LPTSTR pszText;
        int cchText;
    } TBBUTTONINFOA, *LPTBBUTTONINFOA;Contains or receives information for a specific button in a toolbar. cbSize 
    Size of the structure, in bytes. This member must be filled in prior to sending the associated message. 
    dwMask 
    Set of flags that indicate which members contain valid information. This member must be filled in prior to sending the associated message. This can be one or more of the following values: TBIF_COMMAND  The idCommand member contains valid information or is being requested.  
    TBIF_IMAGE  The iImage member contains valid information or is being requested.  
    TBIF_LPARAM  The lParam member contains valid information or is being requested.  
    TBIF_SIZE  The cx member contains valid information or is being requested.  
    TBIF_STATE  The fsState member contains valid information or is being requested.  
    TBIF_STYLE  The fsStyle member contains valid information or is being requested.  
    TBIF_TEXT  The pszText member contains valid information or is being requested.  idCommand 
    Command identifier of the button. 
    iImage 
    Image index of the button. If this member is set to I_IMAGECALLBACK, the toolbar will send the TBN_GETDISPINFO notification to retrieve the image index when it is needed. 
    fsState 
    State flags of the button. This can be one or more of the toolbar button states. 
    fsStyle 
    Style flags of the button. This can be one or more of the toolbar button styles. 
    cx 
    Width of the button, in pixels. 
    lParam 
    Application-defined 32-bit value associated with the button. 
    pszText 
    Address of a character buffer that contains or receives the button text. 
    cchText 
    Size of the buffer at pszText. If the button information is being set, this member is ignored. 
    Toolbar Control and Button Styles
    A toolbar control can have a combination of the following styles: TBSTYLE_ALTDRAG  Allows users to change a toolbar button's position by dragging it while holding down ALT. If this style is not specified, the user must hold down SHIFT while dragging a button. Note that the CCS_ADJUSTABLE style must be specified to enable toolbar buttons to be dragged. 
    TBSTYLE_CUSTOMERASE  Version 4.70. Generates NM_CUSTOMDRAW notification messages when it processesWM_ERASEBKGND messages.  
    TBSTYLE_FLAT  Version 4.70. Creates a flat toolbar. In a flat toolbar, both the toolbar and the buttons are transparent. Button text appears under button bitmaps. To prevent repainting problems, this style should be set before the toolbar control becomes visible.  
    TBSTYLE_LIST  Version 4.70. Places button text to the right of button bitmaps. To prevent repainting problems, this style should be set before the toolbar control becomes visible. 
    TBSTYLE_REGISTERDROP  Version 4.71. Generates TBN_GETOBJECT notification messages to request drop target objects when the pointer passes over toolbar buttons. 
    TBSTYLE_TOOLTIPS  Creates a tooltip control that an application can use to display descriptive text for the buttons in the toolbar. 
    TBSTYLE_TRANSPARENT  Version 4.71. Creates a transparent toolbar. In a transparent toolbar, the toolbar is transparent but the buttons are not. Button text appears under button bitmaps. To prevent repainting problems, this style should be set before the toolbar control becomes visible. 
    TBSTYLE_WRAPABLE  Creates a toolbar that can have multiple lines of buttons. Toolbar buttons can "wrap" to the next line when the toolbar becomes too narrow to include all buttons on the same line. Wrapping occurs on separation and nongroup boundaries. 
    A button in a toolbar can have a combination of the following styles. Not all styles can be combined. TBSTYLE_AUTOSIZE  Version 4.71. The button's width will be calculated based on the text of the button, not on the size of the image.  
    TBSTYLE_BUTTON  Creates a standard push button.  
    TBSTYLE_CHECK  Creates a button that toggles between the pressed and nonpressed states each time the user clicks it. The button has a different background color when it is in the pressed state. 
    TBSTYLE_CHECKGROUP  Creates a check button that stays pressed until another button in the group is pressed. 
    TBSTYLE_DROPDOWN  Version 4.70. Creates a drop-down list button. Drop-down buttons send the TBN_DROPDOWN notification. If the toolbar has the TBSTYLE_EX_DRAWDDARROWS extended style, drop-down buttons will have a drop-down arrow displayed next to them.  
    TBSTYLE_GROUP  Creates a button that stays pressed until another button in the group is pressed. 
    TBSTYLE_NOPREFIX  Version 4.71. The button text will not have an accelerator prefix associated with it. 
    TBSTYLE_SEP  Creates a separator, providing a small gap between button groups. A button that has this style does not receive user input.  
      

  2.   

    非常完整的用API控制Toolbar的例子:
    http://vbaccelerator.com/home/VB/Code/Controls/Toolbar/vbAccelerator_ToolBar_and_CoolMenu_Control/article.asp
      

  3.   

    vbaccelerator.com上的好象是用自己开发的控件写的。MS的控件还没有搞定。老大帮忙把代码给出来学习一下。API刚开始学习,不太会用。另外,想问一下,用BUTTON能直接做出DROPDOWN的风格吗?