How to create on/off LED like lights on a Windows Dialog page, MFC C++ Win32

Posted on 2011-04-22
Last Modified: 2012-06-27
I have a windows MFC dialog page that has numerous on/off buttons. With these buttons I would like to create a LED like object that will show green when on and clear/white when off. I am assuming this will be somekind of bitmap swapping. I am going after a panel look something that one might see with labview. Currently I have check boxes associated with each on/off button that I can check or uncheck as the button is pressed but I want to upgrade to something more visual.
Some example(s) would be best.

My current code is in C++ , Visual Studio 2008, so NO C# stuff
Question by:atomicgs12
    LVL 43

    Expert Comment

    Have a bitmap (for the on button) and display it in a picture control.  You can have numerous ones, one for each on/off switch.

    Then just use
    to control the visibility.  Obviously replace wndBmp1 with the correct control names.

    (Note if you wanted have two bitmaps in separate picture controls placed in the same location to show different pictures for the on/off states)
    LVL 40

    Expert Comment

    In addition, if you want to do blinking lights, you can create a thread to continuously update the controls in the background, or you can install a system timer (using SetTimer() or some such) to call your update callback.
    LVL 86

    Accepted Solution

    The following article pretty much looks like what you would want to do: ("LedButton Status Control (Owner-draw)")

    Author Closing Comment

    Spot on.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
    Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
    The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
    The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now