Virtual Developer Workshop: Containerized Development with Docker


Environment: VC6, NT4 SP4,

These three classes are my attempt at recreating the standard buttons on the Macintosh. The normal appearance of the buttons duplicates the 3D look of the more recent MacOS versions, but an old-style "flat" look can also be used by setting the button's Flat style in the resource editor.

The following public function is available for CMacButton:

  • void SetBold(BOOL bBold = TRUE)
  • BOOL GetBold()

The following public functions are available for CMacCheckBox and CMacRadioButton:

  • void SetCheck(int nCheck)
  • int GetCheck()

Follow these steps to add a CMacXXX button to a dialog:

  • Add the desired files to your project.
  • Add the appropriate include to the header file of your dialog class.
  • Add checkboxes/radio buttons/standard buttons to your dialog in the resource editor.
  • Use ClassWizard to add a member variable of type CMacButton, CMacCheckBox, or CMacRadioButton for the corresponding controls you just added. If the CMacXXX classes are not in the Variable Type list, choose CButton, and manually change the types in the header file of your dialog class.

To do list:

  • Add support for bitmaps on buttons
  • Add support for horizontal and vertical alignment
  • Add support for push-like check boxes and radio buttons
  • Add support for tri-state check boxes and radio buttons


Download demo project - 34 Kb
Download source - 14 Kb


  • Checkbox is checked when using context sensitive help

    Posted by Legacy on 04/08/2002 07:00am

    Originally posted by: Manfred Peter

    Hello Paul,

    first congratulations to your fine work. We use your controls in our project AlligatorSQL - but we had some problems when using this in combination with context sensitive help.
    When we pressed on a checkbox control the value of the box was changed.

    We changed the following line to avoid this problem

    In the function :

    void CMacButtonsCheckBox::OnLButtonUp(UINT nFlags, CPoint point)


    if (rect.PtInRect(point))
    ==> if(m_bMouseDown) m_nCheck = (m_nCheck == 0 ? 1 : 0);

    // Send notify message to parent window.
    // Added by Eric Hwang.

    Thanks again for your controls

    Manfred Peter
    (Alligator Company)

  • value variable and UpdateData...

    Posted by Legacy on 02/18/2002 08:00am

    Originally posted by: DV

    When you create a bolean value variable for the control, you set the variable to 1 and call UpdateData(FALSE) the checkbox state are not updated ?!!!

  • fix resource leak...

    Posted by Legacy on 11/25/2001 08:00am

    Originally posted by: Hyoungsik Woo

    Thansks your work~!

    I found two resource leaks at MacButtons.cpp & one resource leak at MacButtonTestDlg.cpp.
    Add line commented by hswoo.

    ### First resource leak at MacButtons.cpp ################
    ICON CMacButton::SetIcon(HICON hIcon)
    if (hIcon)
    // Get icon dimensions.
    ICONINFO iconInfo;
    ::ZeroMemory(&iconInfo, sizeof(ICONINFO));
    ::GetIconInfo(m_hIcon, &iconInfo);

    m_sizeImage.cx = iconInfo.xHotspot << 1;
    m_sizeImage.cy = iconInfo.yHotspot << 1;

    DeleteObject(iconInfo.hbmColor); // by hswoo.
    DeleteObject(iconInfo.hbmMask); // by hswoo.
    } // SetIcon

    ### Second resource leak at MacButtons.cpp #############
    void CMacButton::DrawPushLikeButton(CDC *pDC, const CRect &rect, UINT nStyle, UINT nState)
    CBrush brFill;

    if (nStyle & BS_FLAT)
    COLORREF crFill = ::GetSysColor(COLOR_WINDOW);

    HBITMAP hBmp = GetDitherBitmap(pDC, crFill, ~crFill);
    CBitmap *pBmp = (hBmp ? CBitmap::FromHandle(hBmp) : NULL);

    if (m_bMouseDown)
    else if (m_nCheck)

    DeleteObject(hBmp); // by hswoo.

    ### resource leak at MacButtonTestDlg.cpp ############
    void CMacButtonTestDlg::OnRadioBitmap()
    HBITMAP hBitmap = ::LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BITMAP1));

    DeleteObject(hBitmap); // by hswoo

  • Make buttons "Tranparent"

    Posted by Legacy on 05/17/2001 07:00am

    Originally posted by: Bernd

    Hi, i found out how to make the buttons transparent, meaning having the same bgtColor like its parentWnd

    To manage it do the following:

    open the CMacButton (Baseclass) cpp File
    goto CMacButton::DrawButton

    seek for

    COLORREF bgColor = ::GetSysColor( COLOR_BTNFACE ); // COLOR_WINDOW

    modify the line to:

    COLORREF bgColor = GetOwner()->GetDC()->GetBkColor();

    That's it!!

    Tu try our set the backgroundcolor of your dialog to white or what ever. so are the Buttons have the same bgColor like your dialog.
    (Lokk especially for MacCheckbox and Macradiobutton)



  • why happens the insuffient resource of a message ??

    Posted by Legacy on 10/27/2000 07:00am

    Originally posted by: kwang young

    i used to click Mac Control button,check button...etc
    but the import massege happened sometime.

    the message was the insuffient resource.

    what's problem ??


  • Make this transparent?

    Posted by Legacy on 07/24/2000 07:00am

    Originally posted by: Trey

    Could someone show me how to make the CMacButton transparent?  I'm new to owner drawn controls and any help would be appreciated.


  • flakey CMacMoreButton response to spacebar

    Posted by Legacy on 04/12/2000 07:00am

    Originally posted by: Rick Shide

    Try the spacebar action on the CMacMoreButton controls. The initial space will open the window up, but the arrow doesn't change to point down, subsequent spacebar on an open CMacMoreButton does nothing. If you then click on the CMacMoreButton after it was opened via a spacebar, the arrow then points down. Then hitting a spacebar on the CMacMoreButton when it is pointing down to an open area closes the area but the arrow remains pointing down.

    Nice controls, but you need to do more testing on response to keyboard.

  • Legal ramifications

    Posted by Legacy on 02/16/2000 08:00am

    Originally posted by: JRB

    Be careful, I read somewhere that Apple does not allow the Mac look and feel to be used in apps running on other OS's

  • tab order & focus on radio

    Posted by Legacy on 12/28/1999 08:00am

    Originally posted by: Rick Shide

    Unlike regular radio controls that are in the tab order, your control allows a tab to unset radio controls in a group. Also, selecting a radio control via the spacebar does not change the selection.

  • Bugs & fix

    Posted by Legacy on 12/26/1999 08:00am

    Originally posted by: eric

    Your mac style buttons are cool!But i've found some bugs:when you click CMacCheckBox or CMacRadioButton,the parent windows can not receive notify message.
    Here is the fix of the CMacCheckBox:
    void CMacCheckBox::OnLButtonUp(UINT nFlags, CPoint point)

    if (rect.PtInRect(point))
    m_bChecked = !m_bChecked;
    //send notify message to parent window
    //added by eric
    CWnd* pParent=GetParent();
    pParent->SendMessage( WM_COMMAND, MAKEWPARAM( GetDlgCtrlID(),BN_CLICKED ), (LPARAM)this->GetSafeHwnd () );
    Fix CMacRadioButton the same way.

  • Loading, Please Wait ...

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date