Click here to Skip to main content
15,881,588 members
Articles / Desktop Programming / MFC
Article

CLedButton

Rate me:
Please Sign up or sign in to vote.
4.47/5 (11 votes)
3 Mar 2000 284K   4.9K   77   18
A button that looks like a LED.

Sample Image - CLedButton.jpg

Introduction

class CLedButton : public CButton (version 1.0)

This is a class which displays a LED that has 2 states: ON or OFF. The LED can have some text on its right. The LED is read-only (on user side) and cannot have focus (you should disable "tab stop" in the resource). The disabled state is not implemented: it is exactly like the enable state.

How to use CLedButton:

  1. To your dialog, add either a button, a checkbox or a radio button.
  2. Bind it to a member variable (of type Control) using Class Wizard.
  3. Then change in the header file, the class type to CLedButton.
  4. In InitDialog(), bind your bitmap resource to the button:
    m_greenLed.SetImage( IDB_LEDBUTTON_GREEN, 15 );
    //15 is the width of one image in the bitmap
  5. You can set or retrieve the state of the LED (ON or OFF) using the following member:
    m_greenLed.Depress(TRUE);  //ON  (second image in bitmap)
    m_greenLed.Depress(FALSE); //OFF (first image in bitmap)

The bitmaps are given with the source code:

  • greenButton.bmp
  • redButton.bmp

Please visit: http://welcome.to/softbird for updates, other sources and more!

The sample project was compiled with Visual C++ 6 (MFC 4.2 ) and not tested with Unicode.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralKingPower Pin
KingPeng25-Jun-06 1:57
KingPeng25-Jun-06 1:57 
GeneralRe: KingPower Pin
zaodt8-May-07 8:29
zaodt8-May-07 8:29 
GeneralCorrected Class Pin
Devil for ever18-May-06 9:36
Devil for ever18-May-06 9:36 
GeneralAnomally behavior with several controls Pin
Anonymous6-Mar-05 22:48
Anonymous6-Mar-05 22:48 
GeneralProblem with CFormView Pin
Seve Ho21-Jul-04 21:31
Seve Ho21-Jul-04 21:31 
QuestionHow to get Tab order and garyed status Pin
tiousi18-Dec-03 6:45
tiousi18-Dec-03 6:45 
Generaldynamically creation of CLedButton Pin
silverspoon15-Jul-02 3:15
silverspoon15-Jul-02 3:15 
GeneralLedButtons with Dialog BAr Pin
murd26-Jan-02 5:14
murd26-Jan-02 5:14 
GeneralPoor Plagiarism Pin
Bill Gates Antimatter Particle25-Nov-01 7:15
Bill Gates Antimatter Particle25-Nov-01 7:15 
GeneralRe: Poor Plagiarism Pin
Shaun Harrington21-Feb-06 13:12
Shaun Harrington21-Feb-06 13:12 
GeneralRed - Green Toggle Pin
Mark Kozel6-Nov-01 12:09
Mark Kozel6-Nov-01 12:09 
GeneralMinor alignment bug... Pin
Kevin Pinkerton6-Jun-01 6:01
Kevin Pinkerton6-Jun-01 6:01 
GeneralRe: Minor alignment bug... Pin
6-Jun-01 8:30
suss6-Jun-01 8:30 
QuestionIf I do dialog docking, how I can show LED Button and control? Pin
30-Mar-01 18:02
suss30-Mar-01 18:02 
Confused | :confused: If I do docking, how I can show LED Button and control? Confused | :confused:
---------------------------------------------------------

I study MFC, and I intereted in your LED Button Source.
So, I made the dialog of your LED Button docked.
but, I can't see your bitmap LED Button. and contol,
How can I do? Please Help Me!!!!


pcstone@shinbiro.com

AnswerRe: If I do dialog docking, how I can show LED Button and control? Pin
6-Jun-01 5:22
suss6-Jun-01 5:22 
Generalcledbutton Pin
Member 55024118-Jun-00 14:43
Member 55024118-Jun-00 14:43 
GeneralRe: cledbutton Pin
Benjamin Mayrargue20-Jul-00 6:53
Benjamin Mayrargue20-Jul-00 6:53 
GeneralRe: cledbutton Pin
Kevin Pinkerton6-Jun-01 3:35
Kevin Pinkerton6-Jun-01 3:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.