Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

CLedButton

0.00/5 (No votes)
3 Mar 2000 1  
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