Using CSplitButton in VC6
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 2 of 2

Thread: Using CSplitButton in VC6

  1. #1
    Join Date
    Jan 2009

    Using CSplitButton in VC6

    Is there any chance to use CSplitButton in VC6 ?
    I had tried to use something appropriate founded on CP, but they are using DrawItem, and I had problems with windows style, and I had tried to make myself one, overriding OnPaint, but I front with flickering (I put the sample below)... so, I wonder if I could get (from somewhere) CSplitButton and add to my project ... if you say that I could, can you provide me the CSplitButton source code ? I mean, only .cpp implementation file ...

    Thank you.
    Attached Files Attached Files
    Last edited by mesajflaviu; December 5th, 2013 at 07:17 AM.

  2. #2
    ovidiucucu's Avatar
    ovidiucucu is offline Moderator/Reviewer Power Poster
    Join Date
    Feb 2003
    Iasi - Romania

    Re: Using CSplitButton in VC6

    Much simpler:
    If the target OS is Windows Vista or newer, you can make from an ordinary push button a split button by adding BS_SPLITBUTTON or BS_DEFSPLITBUTTON style.
    Next, just handle BCN_DROPDOWN (reflected) notification and do something cool, e.g. show a drop-down menu.

    // MySplitButton.h
    #pragma once
    class CMySplitButton : public CButton
        // ...
        virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
        virtual void PreSubclassWindow();
        // ...
        afx_msg void OnBnDropDown(NMHDR *pNMHDR, LRESULT *pResult);
    // MySplitButton.cpp
    // ...
        // ...
    // ...
    BOOL CMySplitButton::PreCreateWindow(CREATESTRUCT& cs)
        return CButton::PreCreateWindow(cs);
    void CMySplitButton::PreSubclassWindow()
        ModifyStyle(0, BS_SPLITBUTTON);
    void CMySplitButton::OnBnDropDown(NMHDR *pNMHDR, LRESULT *pResult)
        LPNMBCDROPDOWN pDropDown = reinterpret_cast<LPNMBCDROPDOWN>(pNMHDR);
        // Do something here, e.g. show a drop-down menu.
        *pResult = 0;
    If you are using an older SDK (like the one which comes with VS6.0), you can define missing constants and structures as follows:
    #ifndef BCN_FIRST
    #define BCN_FIRST           (0U-1250U)
    #define BCN_DROPDOWN        (BCN_FIRST + 0x0002)
    #define BS_SPLITBUTTON      0x0000000CL
    #define BS_DEFSPLITBUTTON   0x0000000DL
    typedef struct tagNMBCDROPDOWN
        NMHDR   hdr;
        RECT    rcButton;
    #endif // BCN_FIRST
    Alternatively and much better, get rid of old VS6.0 and use a newer one. Visual Studio 2008 and newer, comes with a split button control resource and a CSplitButton class which
    do the work for you.
    Ovidiu Cucu
    "When in Rome, do as Romans do."
    Visit: Microsoft Virtual Academy
    My blog:

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Azure Activities Information Page

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


HTML5 Development Center