Guidance
指路人
g.yi.org
software / rapidq / Examples / Date & Time / rqWatch / rqwatch.bas

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
'####################
'####  rqWatch   ####
'####################
'Created by Bruno Schäfer, August 2000 [bup.schaefer@planet-interkom.de]
'all .bmp and .wav files should be in the same directory like this

     $INCLUDE "RAPIDQ.INC"
     $RESOURCE res_ledon AS "ledon.bmp"
     $RESOURCE res_ledoff AS "ledoff.bmp"
     $RESOURCE res_sound AS "Alarm.wav"
     DECLARE SUB  iCoolBtnClick (Sender AS QCOOLBTN)
     DECLARE SUB  cCoolBtnClick (Sender AS QCOOLBTN)
     DECLARE SUB AlCoolBtn1Click (Sender AS QCOOLBTN)
     DECLARE SUB AlCoolBtn2Click (Sender AS QCOOLBTN)
     DECLARE SUB AlCoolBtn3Click (Sender AS QCOOLBTN)
     DECLARE SUB StCoolBtn1Click (Sender AS QCOOLBTN)
     DECLARE SUB StCoolBtn2Click (Sender AS QCOOLBTN)
     DECLARE SUB StCoolBtn3Click (Sender AS QCOOLBTN)
     DECLARE SUB cCoolBtnClick (Sender AS QCOOLBTN)
     DECLARE SUB iCoolBtnClick (Sender AS QCOOLBTN)
     DECLARE SUB RadioButton1Click (Sender AS QRADIOBUTTON)
     DECLARE SUB RadioButton2Click (Sender AS QRADIOBUTTON)
     DECLARE SUB StStartBtnClick (Sender AS QBUTTON)
     DECLARE SUB EndButtonClick (Sender AS QBUTTON)
     DECLARE SUB ResButtonClick (Sender AS QBUTTON)
     DECLARE SUB Timer1Over (Sender AS QTIMER)
     DECLARE SUB Timer2Over (Sender AS QTIMER)
     DIM alsek$ AS STRING : DIM almin$ AS STRING : DIM alstu$ AS STRING
     DIM stsek$ AS STRING : DIM stlmin$ AS STRING : DIM ststu$ AS STRING
     DIM STOPPtext$ AS STRING
     DIM WeckerAn AS INTEGER
     DIM sth AS INTEGER : DIM stm AS INTEGER : DIM sts AS INTEGER
     DIM StoppMethode$ AS STRING
     alsek$ = "00" : almin$ = "00" : alstu$ = "00"
     stsek$ = "00" : stmin$ = "00" : ststu$ = "00"
     sts = 0 : stm = 0 : sth = 0
     STOPPtext$ = "Start"
     WeckerAn = 0
     StoppMethode$ = "countup"
' ------------GUI-Konstruktion-------------------------
     CREATE Timer1 AS QTIMER
      OnTimer = Timer1Over
     END CREATE
     CREATE Timer2 AS QTIMER
      Enabled = 0
     END CREATE
     CREATE Form AS QFORM
      CAPTION = "rqTimer"
      Width = 200
      Height = 215
      BorderStyle = bsToolWindow
      Center
      CREATE Label1 AS QLABEL
       CAPTION = "Time"
       Left = 8
       Top = 0
       Width = 40
       Transparent = 1
      END CREATE
      CREATE iCoolBtn AS QCOOLBTN
       CAPTION = "i"
       Left = 136
       Top = 0
       Width = 23
       Height = 22
       OnClick = iCoolBtnClick
       ShowHint = 1
       Hint = "info"
      END CREATE
      CREATE cCoolBtn AS QCOOLBTN
       CAPTION = "(c)"
       Left = 160
       Top = 0
       Width = 23
       Height = 22
       OnClick = cCoolBtnClick
       ShowHint = 1
       Hint = "author/copyright"
      END CREATE
      CREATE Panel1 AS QPANEL
       Left = 8
       Top = 16
       Width = 49
       Height = 25
       BevelInner = 1
       BevelOuter = 1
       COLOR = 986434567
       ShowHint = 1
       Hint = "actual time"
      END CREATE
      CREATE EndButton AS QBUTTON
       CAPTION = "Exit"
       Left = 136
       Top = 23
       Width = 48
       Height = 19
       TabOrder = 1
       OnClick = EndButtonClick
       ShowHint = 1
       Hint = "exit rqTimer program"
      END CREATE
      CREATE Panel2 AS QPANEL
       Alignment = 0 : Left = 59 : Top = 1 : CAPTION = " ALARM": Width = 73
       BevelInner = 1 : TabOrder = 2 : ShowHint = 1 : Hint = "alarmwatch on/off"
       CREATE Image1 AS QIMAGE
        BMPHandle = res_ledoff
        Left = 47
        Top = 11
        Width = 20
        Height = 20
        Stretch = 1
        ShowHint = 1
        Hint = "alarm control lamp"
       END CREATE
      END CREATE
      CREATE Panel3 AS QPANEL
       Left = 8
       Top = 48
       Width = 87
       Height = 137
       BevelInner = 1
       TabOrder = 3
       CREATE AlCoolBtn1 AS QCOOLBTN
        CAPTION = "h"
        Left = 8
        Top = 48
        Width = 23
        Height = 22
        OnClick = AlCoolBtn1Click
        ShowHint = 1
        Hint = "Alarm hour value"
       END CREATE
       CREATE AlCoolBtn2 AS QCOOLBTN
        CAPTION = "m"
        Left = 32
        Top = 48
        Width = 23
        Height = 22
        OnClick = AlCoolBtn2Click
        ShowHint = 1
        Hint = "Alarm minutes value"
       END CREATE
       CREATE AlCoolBtn3 AS QCOOLBTN
        CAPTION = "s"
        Left = 56
        Top = 48
        Width = 23
        Height = 22
        OnClick = AlCoolBtn3Click
        ShowHint = 1
        Hint = "Alarm seconds value"
       END CREATE
       CREATE Label2 AS QLABEL
        CAPTION = "Alarmwatch"
        Left = 8
        Top = 8
        Width = 58
        Transparent = 1
       END CREATE
       CREATE alPanel AS QPANEL
        Left = 8
        Top = 24
        CAPTION = alstu$ + ":" + almin$ + ":" + alsek$
        Width = 71
        Height = 25
        BevelInner = 1
       END CREATE
       CREATE GroupBox1 AS QGROUPBOX
        CAPTION = "Alarm"
        Left = 6
        Top = 74
        Width = 73
        Height = 57
        TabOrder = 1
        ShowHint = 1
        Hint = "Alarm on / off"
        CREATE RadioButton1 AS QRADIOBUTTON
         CAPTION = "on"
         Left = 8
         Top = 16
         Width = 49
         OnClick = RadioButton1Click
        END CREATE
        CREATE RadioButton2 AS QRADIOBUTTON
         CAPTION = "off"
         Checked = 1
         Left = 8
         Top = 32
         Width = 49
         TabOrder = 1
         OnClick = RadioButton2Click
        END CREATE
       END CREATE
      END CREATE
      CREATE Panel4 AS QPANEL
       Left = 96
       Top = 48
       Width = 89
       Height = 137
       BevelInner = 1
       TabOrder = 4
       CREATE StCoolBtn1 AS QCOOLBTN
        CAPTION = "h"
        Left = 8
        Top = 48
        Width = 23
        Height = 22
        OnClick = StCoolBtn1Click
        ShowHint = 1
        Hint = "set stopwatch-hour"
       END CREATE
       CREATE StCoolBtn2 AS QCOOLBTN
        CAPTION = "m"
        Left = 32
        Top = 48
        Width = 23
        Height = 22
        OnClick = StCoolBtn2Click
        ShowHint = 1
        Hint = "set stopwatch minute"
       END CREATE
       CREATE StCoolBtn3 AS QCOOLBTN
        CAPTION = "s"
        Left = 56
        Top = 48
        Width = 23
        Height = 22
        OnClick = StCoolBtn3Click
        ShowHint = 1
        Hint = "set stopwatch second"
       END CREATE
       CREATE Label3 AS QLABEL
        CAPTION = "Stopwatch"
        Left = 8
        Top = 8
        Width = 56
       END CREATE
       CREATE StPanel AS QPANEL
        Left = 8
        Top = 24
        CAPTION = ststu$ + ":" + stmin$ + ":" + stsek$
        Width = 71
        Height = 25
        BevelInner = 1
       END CREATE
       CREATE StStartButton AS QBUTTON
        CAPTION = "Start"
        Left = 8
        Top = 80
        Width = 71
        TabOrder = 1
        ShowHint = 1
        Hint = "stopwatch Start/Stop"
        OnClick = StStartBtnClick
       END CREATE
       CREATE ResButton AS QBUTTON
        CAPTION = "Reset"
        Left = 8
        Top = 104
        Width = 71
        TabOrder = 2
        ShowHint = 1
        Hint = "stopwatch reset to zero"
        OnClick = ResButtonClick
       END CREATE
      END CREATE
     END CREATE
     Form.SHOWMODAL
'--------------------Subroutine--Timer--UHRZEIt-----------
     SUB Timer1Over (Sender AS QTIMER)
      Timer1.Interval = 1000
      Timer1.Enabled = 1
      Panel1.CAPTION = TIME$
      IF LEFT$(TIME$ , 7) = alstu$ + ":" + almin$ + ":" + LEFT$(alsek$,1) AND WeckerAn = 1 THEN
       PLAYWAV res_sound , SND_ASYNC
      END IF
     END SUB
'--------------------Subroutine--Timer--STOPPUHR----------------------
     SUB Timer2Over (Sender AS QTIMER)
      Timer2.Interval = 1000
'----------Stoppuhrmethoden und Zählen
      SELECT CASE StoppMethode$
      CASE "countup"                           ' hochzählen
       sts = sts + 1

       IF sts = 60 THEN
        stm = stm + 1
        sts = 0
       END IF
       IF  stm = 60 THEN
        sth = sth + 1
        stm = 0
       END IF
      CASE "countdown"                        'runterzählen
       sts = sts - 1
       IF sts = -1 THEN
        sts = 59
        stm = stm - 1
        IF  stm = -1 THEN
         sth = sth - 1
         stm = 59
        END IF
       END IF
       IF sth = 0 AND stm = 0 AND sts = 0 THEN
        PLAYWAV res_sound, SND_ASYNC


        StoppMethode$ = "countup"
       END IF
      END SELECT
'---------Formatierung und Ausgabe der Stoppzeit
      ststu$ = STR$(sth) : stmin$ = STR$(stm) : stsek$ = STR$(sts)
      IF LEN(stsek$) < 2 THEN stsek$ = "0" + stsek$
      IF LEN(stmin$) < 2 THEN stmin$ = "0" + stmin$
      IF LEN(ststu$) < 2 THEN ststu$ = "0" + ststu$
      stPanel.CAPTION =  ststu$ + ":" + stmin$ + ":" + stsek$
     END SUB
'--------------------Subroutines------Werteinstellungen-----------
     SUB AlCoolBtn1Click (Sender AS QCOOLBTN)
      alstu$ = STR$(VAL(alstu$) +1)
      IF VAL (alstu$) = 24 THEN alstu$ = "00"
      IF LEN(alstu$) < 2 THEN alstu$ = "0" + alstu$
      AlPanel.CAPTION =  alstu$ + ":" + almin$ + ":" + alsek$
     END SUB
     SUB AlCoolBtn2Click (Sender AS QCOOLBTN)
      almin$ = STR$(VAL(almin$) +1)
      IF VAL (almin$) = 60 THEN almin$ = "00"
      IF LEN(almin$) < 2 THEN almin$ = "0" + almin$
      AlPanel.CAPTION =  alstu$ + ":" + almin$ + ":" + alsek$
     END SUB
     SUB AlCoolBtn3Click (Sender AS QCOOLBTN)
      alsek$ = STR$(VAL(alsek$) +1)
      IF VAL (alsek$) = 60 THEN alsek$ = "00"
      IF LEN(alsek$) < 2 THEN alsek$ = "0" + alsek$
      AlPanel.CAPTION =  alstu$ + ":" + almin$ + ":" + alsek$
     END SUB
     SUB StCoolBtn1Click (Sender AS QCOOLBTN)
      ststu$ = STR$(VAL(ststu$) +1)
      IF VAL (ststu$) = 60 THEN ststu$ = "00"
      IF LEN(ststu$) < 2 THEN ststu$ = "0" + ststu$
      stPanel.CAPTION =  ststu$ + ":" + stmin$ + ":" + stsek$
     END SUB
     SUB StCoolBtn2Click (Sender AS QCOOLBTN)
      stmin$ = STR$(VAL(stmin$) +1)
      IF VAL (stmin$) = 60 THEN stmin$ = "00"
      IF LEN(stmin$) < 2 THEN stmin$ = "0" + stmin$
      stPanel.CAPTION =  ststu$ + ":" + stmin$ + ":" + stsek$
     END SUB
     SUB StCoolBtn3Click (Sender AS QCOOLBTN)
      stsek$ = STR$(VAL(stsek$) +1)
      IF VAL (stsek$) = 60 THEN stsek$ = "00"
      IF LEN(stsek$) < 2 THEN stsek$ = "0" + stsek$
      stPanel.CAPTION =  ststu$ + ":" + stmin$ + ":" + stsek$
     END SUB
'----------------------------------------------------------------------
     SUB cCoolBtnClick (Sender AS QCOOLBTN)
      SHOWMESSAGE "(c) August 2000, Bruno Schäfer: Feel free to copy !!!"
     END SUB
     SUB iCoolBtnClick (Sender AS QCOOLBTN)
      SHOWMESSAGE "rqWatch Version 1.00: Powered by Rapid-Q "
     END SUB
     SUB RadioButton1Click (Sender AS QRADIOBUTTON)    'Wecker-Alarm an
      RadioButton1.Checked = 1
      Image1.BMPHandle = res_ledon
      WeckerAn = 1
     END SUB
     SUB RadioButton2Click (Sender AS QRADIOBUTTON)     'Wecker-Alarm aus
      RadioButton2.Checked = 1
      Image1.BMPHandle = res_ledoff
      WeckerAn = 0
     END SUB
'-----------Stoppuhrsteuerung-----------------------------------------
     SUB StStartBtnClick (Sender AS QBUTTON)
      sth = VAL(ststu$) : stm = VAL(stmin$) : sts = VAL(stsek$)          ' Wertübergabe
      SELECT CASE STOPPtext$
      CASE "Start"
       STOPPtext$ = "Stop"                                         ' Stoppuhr starten
       IF ststu$ + ":" + stmin$ + ":" + stsek$ = "00:00:00" THEN
        StoppMethode$ = "countup"
       ELSE
        StoppMethode$ = "countdown"
       END IF
       Timer2.OnTimer = Timer2Over
       Timer2.Enabled = 1
      CASE "Stop"
       STOPPtext$ =  "Start"
       Timer2.Enabled = 0                                          'Stoppuhr anhalten
      END SELECT
      StStartButton.CAPTION = STOPPtext$
     END SUB
     SUB ResButtonClick (Sender AS QBUTTON)
      stsek$ = "00" : stmin$ = "00" : ststu$ = "00"
      sth = VAL(ststu$) : stm = VAL(stmin$) : sts = VAL(stsek$)
      stPanel.CAPTION =  ststu$ + ":" + stmin$ + ":" + stsek$
     END SUB
'--------Programm beenden--------------------------------------------
     SUB  EndButtonClick (Sender AS QBUTTON)
      Form.CLOSE 'End of rqTimer
     END SUB

掌柜推荐
 
 
¥289.00 ·
 
 
¥1,080.00 ·
 
 
¥1,380.00 ·
 
 
¥638.00 ·
 
 
¥1,290.00 ·
 
 
¥1,420.00 ·
© Sun 2024-11-24  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2000-10-07 17:51:04