Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Newbie question
Message
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Title:
Miscellaneous
Thread ID:
00654364
Message ID:
00654644
Views:
23
**************************************************
*-- Class Library: c:\documents and settings\administrator\my documents\my received files\led\led.vcx
**************************************************


**************************************************
*-- Class: led (c:\documents and settings\administrator\my documents\my received files\led\led.vcx)
*-- ParentClass: container
*-- BaseClass: container
*-- Time Stamp: 05/09/02 12:43:12 PM
*
DEFINE CLASS led AS container


Width = 22
Height = 22
BackStyle = 0
BorderWidth = 0
*-- Set the color of the LED: Options: Red, Blue, Yellow, Green, Magenta
ccolor = "Red"
*-- The amount of time between each blink.
nblinkinterval = 7500
*-- The amount of time the LED stays lit.
nblinkrate = 2500
Name = "led"

*-- Causes the LED to blink on and off.
lblink = .T.


ADD OBJECT blinktimer AS timer WITH ;
Top = -2, ;
Left = -2, ;
Height = 18, ;
Width = 18, ;
Enabled = .F., ;
Name = "BlinkTimer"


ADD OBJECT ledoff AS image WITH ;
Picture = "offled.bmp", ;
BackStyle = 0, ;
Height = 20, ;
Left = 0, ;
Top = 0, ;
Width = 20, ;
Name = "LedOff"


ADD OBJECT red AS image WITH ;
Picture = "redled.bmp", ;
BackStyle = 0, ;
Height = 20, ;
Left = 0, ;
Top = 0, ;
Visible = .F., ;
Width = 20, ;
Name = "Red"


ADD OBJECT blue AS image WITH ;
Picture = "blueled.bmp", ;
BackStyle = 0, ;
Height = 20, ;
Left = 0, ;
Top = 0, ;
Visible = .F., ;
Width = 20, ;
Name = "Blue"


ADD OBJECT magenta AS image WITH ;
Picture = "magentaled.bmp", ;
BackStyle = 0, ;
Height = 20, ;
Left = 0, ;
Top = 0, ;
Visible = .F., ;
Width = 20, ;
Name = "Magenta"


ADD OBJECT green AS image WITH ;
Picture = "greenled.bmp", ;
BackStyle = 0, ;
Height = 20, ;
Left = 0, ;
Top = 0, ;
Visible = .F., ;
Width = 20, ;
Name = "Green"


ADD OBJECT yellow AS image WITH ;
Picture = yellowled.bmp", ;
BackStyle = 0, ;
Height = 20, ;
Left = 0, ;
Top = 0, ;
Visible = .F., ;
Width = 20, ;
Name = "Yellow"


*-- Turn the LED on/off.
PROCEDURE flick
LOCAL cColor

cColor = THIS.cColor

IF THIS.lBlink
THIS.blinkTimer.ENABLED = !THIS.blinkTimer.ENABLED
** Had to add this to make sure the timer doesn't leave the light on.
** Bad timer, bad timer!
IF !THIS.blinkTimer.ENABLED
THIS.&cColor..VISIBLE = .F.
this.BlinkTimer.interval = this.nBlinkInterval
ENDIF
ELSE
THIS.&cColor..VISIBLE = !THIS.&cColor..VISIBLE
ENDIF
ENDPROC


*-- Help - Readme for this class
PROCEDURE readme
*-----------------------------------------------------------------------
* Class: LED
*-----------------------------------------------------------------------
* Programmer: Roi Ledford
*-----------------------------------------------------------------------
* What is it?
* LED is a small round LED light that you can place on
* a form.
*-----------------------------------------------------------------------
* Propeties:
* cColor:
* The color of the LED. There are 5 available
* Red, Blue, Yellow, Green, Magenta.
*
* lBlink:
* Switch to determine whether the LED blinks
*
* nBlinkInterval:
* The amount of time between blinks. (in milliseconds)
*
* nBlinkRate:
* The amount of time it stays lit. (in milliseconds)
*
*-----------------------------------------------------------------------
* Methods:
* Flick:
* This turns the LED on/off. If lBlink is .t., the LED
* will wait the duration of nblinkInterval, turn on for
* nBlinkRate and then start over.
*-----------------------------------------------------------------------
* Required files:
* This uses the following .bmp's to display the LED
* LedRed.bmp
* LedBlue.bmp
* LedYellow.bmp
* LedGreen.bmp
* LedMagenta.bmp
* LedOff.bmp
*-----------------------------------------------------------------------
* Notes:
* Don't screw with the order of the imgs in the class. I don't
* change the .visible of the imgLedOff. It is always visible, so
* it has to be the bottom object, Poor LedOff.
*-----------------------------------------------------------------------
* That's it. Just drop this on a form and call the flick method.
* Feel free to play, change, whatever with it, it is granted to
* the public domain.
*
ENDPROC


PROCEDURE blinktimer.Timer
LOCAL cColor

** Change the LED viisibility
cColor = THIS.parent.cColor
THIS.parent.&cColor..VISIBLE = !THIS.parent.&cColor..VISIBLE

** Change the timer interval to the BlinkRate
IF THIS.INTERVAL = THIS.PARENT.nBlinkInterval
THIS.INTERVAL = THIS.PARENT.nBlinkRate
ELSE
THIS.INTERVAL = THIS.PARENT.nBlinkInterval
ENDIF
ENDPROC


PROCEDURE blinktimer.Init
this.interval = this.parent.nBlinkInterval
ENDPROC


ENDDEFINE
*
*-- EndDefine: led
**************************************************
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform