Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

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

Posted on 2011-04-22
4
Medium Priority
?
1,409 Views
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
Thanks
0
Comment
Question by:atomicgs12
4 Comments
 
LVL 45

Expert Comment

by:AndyAinscow
ID: 35448058
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
wndBmp1.ShowWindow(SW_SHOW);
or
wndBmp1.ShowWindow(SW_HIDE);
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)
0
 
LVL 40

Expert Comment

by:mrjoltcola
ID: 35448357
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.
0
 
LVL 86

Accepted Solution

by:
jkr earned 2000 total points
ID: 35448566
The following article pretty much looks like what you would want to do: http://www.codeproject.com/KB/buttons/LedButton.aspx ("LedButton Status Control (Owner-draw)")
0
 

Author Closing Comment

by:atomicgs12
ID: 35451078
Spot on.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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 learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

571 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