December 5th, 2013, 07:23 AM
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 ...
Last edited by mesajflaviu; December 5th, 2013 at 08:17 AM.
December 5th, 2013, 09:17 AM
Re: Using CSplitButton in VC6
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.
class CMySplitButton : public CButton
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
virtual void PreSubclassWindow();
afx_msg void OnBnDropDown(NMHDR *pNMHDR, LRESULT *pResult);
If you are using an older SDK (like the one which comes with VS6.0), you can define missing constants and structures as follows:
BOOL CMySplitButton::PreCreateWindow(CREATESTRUCT& cs)
cs.style |= 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;
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
#define BCN_FIRST (0U-1250U)
#define BCN_DROPDOWN (BCN_FIRST + 0x0002)
#define BS_SPLITBUTTON 0x0000000CL
#define BS_DEFSPLITBUTTON 0x0000000DL
typedef struct tagNMBCDROPDOWN
} NMBCDROPDOWN, * LPNMBCDROPDOWN;
#endif // BCN_FIRST
do the work for you.
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!