65.9K
CodeProject 正在变化。 阅读更多。
Home

CLedButton

starIconstarIconstarIconstarIcon
emptyStarIcon
starIcon

4.47/5 (10投票s)

2000 年 3 月 4 日

viewsIcon

286931

downloadIcon

4909

一个看起来像LED的按钮。

Sample Image - CLedButton.jpg

引言

class CLedButton : public CButton (version 1.0)

这是一个显示LED的类,具有两种状态:开启或关闭。LED可以在其右侧显示一些文本。LED是只读的(用户端),并且不能获得焦点(您应该在资源中禁用“选项卡停靠”)。禁用状态未实现:它与启用状态完全相同。

如何使用CLedButton

  1. 在您的对话框中,添加一个按钮、复选框或单选按钮。
  2. 使用“类向导”将其绑定到成员变量(类型为Control)。
  3. 然后在头文件中,将类类型更改为CLedButton
  4. InitDialog()中,将您的位图资源绑定到按钮。
    m_greenLed.SetImage( IDB_LEDBUTTON_GREEN, 15 );
    //15 is the width of one image in the bitmap
  5. 您可以使用以下成员设置或检索LED的状态(开启或关闭)。
    m_greenLed.Depress(TRUE);  //ON  (second image in bitmap)
    m_greenLed.Depress(FALSE); //OFF (first image in bitmap)

位图随源代码提供。

  • greenButton.bmp
  • redButton.bmp

请访问: http://welcome.to/softbird 以获取更新、其他资源和更多信息!

示例项目使用 Visual C++ 6 (MFC 4.2) 编译,未用 Unicode 测试过。

© . All rights reserved.