CMacButton, CMacCheckBox '& CMacRadioButton

ColorLBTest

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

Downloads

Download demo project - 34 Kb
Download source - 14 Kb


Comments

  • Jordan shoes mentioned Gene to go for the manufacturer, a disunion of Nike

    Posted by TaddyGaffic on 04/22/2013 07:12pm

    The sole of shoes are made from high quality rubber material and come with the lining. One can easily search for Vans footwear in the various online stores where they are easily available at great discount prices. These come in almost an infinite amount of [url=http://markwarren.org.uk/goodbuy.cfm]nike free run[/url] color and are usually on the cheap side. Experts as well as the rights of employees in regards to the apple can annihilate the Nike Air Max For travel arrangements in developing abjection can be a acceptable accord added in comparison to they're prevention, nonetheless they do accommodate sports sports athletes while using high duke inside their profession. Bargain Nike Air Max 2009 aswell provides countless jobs inside the nations absolutely area it's hardly accessible to acquire a job. In Indonesia, for archetype nike air max 90, even acknowledging baby assets [url=http://markwarren.org.uk/property-waet.cfm]air max 90[/url] in barter for plan Air Max, however, Nike bargain shoes inside a aught bulk adaptation and utilisation of the circadian needs.. Nike Zoom Vapor VI Tour Men`s tennis shoe is a great shoe popular in the tennis courts. It has Fly wire upper for ultra support and light weight ability, it sits on a frame that gives extra heel support and contains a full-length durable rubber support and herring bone pattern. It also has extra traction for all surfaces of play.. Write a Shakespeare Sonnet without any effort! Express loving [url=http://markwarren.org.uk/goodbuy.cfm]nike free run uk[/url] feelings in a sonnet in Shakespeare's own words in 15 minutes. The rhyme scheme of a Sonnet is a,b,a,b,c,d,c,d,e,f,e,f,g,g. Think of a theme like "love" "death" or "deceit", then choose your lines in the rhyme pattern and put a Sonnet together using the programme

    Reply
  • Checkbox is checked when using context sensitive help

    Posted by Legacy on 04/08/2002 12: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)
    http://www.alligatorsql.com


    Reply
  • value variable and UpdateData...

    Posted by Legacy on 02/18/2002 12: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 ?!!!

    Reply
  • fix resource leak...

    Posted by Legacy on 11/25/2001 12: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);
    ASSERT(pBmp);

    if (m_bMouseDown)
    brFill.CreatePatternBrush(pBmp);
    else if (m_nCheck)
    brFill.CreateSolidBrush(~crFill);
    else
    brFill.CreateSolidBrush(crFill);

    DeleteObject(hBmp); // by hswoo.
    ...
    }

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

    ...
    GetDlgItem(IDC_STATIC_IMAGEEFFECT)->EnableWindow();
    m_radioNone.EnableWindow();
    m_radioRaised.EnableWindow();
    m_radioSunken.EnableWindow();
    DeleteObject(hBitmap); // by hswoo
    }

    Reply
  • Make buttons "Tranparent"

    Posted by Legacy on 05/17/2001 12: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)

    Greetings

    Bernd

    Reply
  • why happens the insuffient resource of a message ??

    Posted by Legacy on 10/27/2000 12: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 ??

    please...

    Reply
  • Make this transparent?

    Posted by Legacy on 07/24/2000 12: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.
    
    

    Thanks,
    Trey

    Reply
  • flakey CMacMoreButton response to spacebar

    Posted by Legacy on 04/12/2000 12: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.

    Reply
  • Legal ramifications

    Posted by Legacy on 02/16/2000 12: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

    Reply
  • tab order & focus on radio

    Posted by Legacy on 12/28/1999 12: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.

    Reply
  • Loading, Please Wait ...

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

Top White Papers and Webcasts

  • Packaged application development teams frequently operate with limited testing environments due to time and labor constraints. By virtualizing the entire application stack, packaged application development teams can deliver business results faster, at higher quality, and with lower risk.

  • Java developers know that testing code changes can be a huge pain, and waiting for an application to redeploy after a code fix can take an eternity. Wouldn't it be great if you could see your code changes immediately, fine-tune, debug, explore and deploy code without waiting for ages? In this white paper, find out how that's possible with a Java plugin that drastically changes the way you develop, test and run Java applications. Discover the advantages of this plugin, and the changes you can expect to see …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds