Page 1 of 1

Small watch thread

Posted: Wed Jul 10, 2013 8:17 pm
by minimy
This is a very basic small clock.

Code: Select all

; Por Toni 2013


Procedure Reloj(Gadget.l)
  Repeat
    hora.s=FormatDate("%hh:%ii:%ss",Date())
    If hora<>GetGadgetText(Gadget)
      SetGadgetText(Gadget,hora)
    EndIf
    Delay(500)
  ForEver
EndProcedure



CompilerIf  Not #PB_Compiler_IsIncludeFile
  
Global Window_0
Global Text_0
Define.l Event, EventWindow, EventGadget, EventType, EventMenu
Procedure OpenWindow_Window_0()
  Window_0 = OpenWindow(#PB_Any, 428, 33, 615, 400, "Window_0", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MinimizeGadget|#PB_Window_TitleBar)
  If Window_0
    Text_0 = TextGadget(#PB_Any, 10, 10, 280, 45, "0", #PB_Text_Border|#PB_Text_Center|#SS_CENTERIMAGE)
  EndIf
EndProcedure

OpenWindow_Window_0()
CreateThread(@Reloj(),Text_0)

Repeat
  Event = WaitWindowEvent(1)
  Select Event
    Case #PB_Event_Gadget
      EventGadget = EventGadget()
      EventType = EventType()
      If EventGadget = Text_0
      EndIf
    Case #PB_Event_CloseWindow
      EventWindow = EventWindow()
      If EventWindow = Window_0
        CloseWindow(Window_0)
        Window_0 = 0
        Break
      EndIf
  EndSelect
ForEver

CompilerEndIf

Its to late!! ;-)