Page 1 sur 1

afficher les seconde a l'ouverture

Publié : mer. 01/mars/2006 20:36
par venom
bonjour.

voici ma question je n'arrive pas a faire pour qu'a l'ouverture de ma fenetre s'afiche les seconde en temps reel tout le temps que ma fenetre reste ouvert.

si vous avez pas comprit merci de me le faire part :D

voici un exemple

Code : Tout sélectionner

;- Window Constants
Enumeration
  #Window_0
EndEnumeration

;- Gadget Constants
Enumeration
  #Text_0
  #Text_1
  #Text_2
EndEnumeration

;liste chainee

;- Fonts
Global FontID1
FontID1 = LoadFont(1, "Georgia", 10)
Global FontID2
FontID2 = LoadFont(2, "Comic Sans MS", 10, #PB_Font_Bold)
Global FontID3
FontID3 = LoadFont(3, "Comic Sans MS", 10, #PB_Font_Bold | #PB_Font_Italic)

  If OpenWindow(#Window_0, 216, 0, 240, 120,  #PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_ScreenCentered , "exemple")
    If CreateGadgetList(WindowID())

      TextGadget(#Text_1, 5, 50, 230, 20, "temps de connexion :  "+time$)
      SetGadgetFont(#Text_1, FontID3)

    EndIf
  EndIf
  
  Repeat 
  event = WaitWindowEvent() 
  If event = #PB_EventGadget 
    Select EventGadgetID() 

    EndSelect 
  EndIf  
Until event = #PB_EventCloseWindow
desoler c'est court j'ai pas trop le temps la


@++

Publié : mer. 01/mars/2006 21:07
par Flype
comme çà ? :D

Code : Tout sélectionner

FontID0 = LoadFont(0, "Comic Sans MS", 10, #PB_Font_Bold | #PB_Font_Italic)

If OpenWindow(0, 216, 0, 240, 120,  #PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_ScreenCentered , "exemple")
  If CreateGadgetList(WindowID(0))
    TextGadget(0, 5, 50, 230, 20,"")
    SetGadgetFont(0,FontID0)
  EndIf
EndIf

SetTimer_(WindowID(0),1,100,#Null)

StartTime.l = ElapsedMilliseconds()

Repeat
  Select WaitWindowEvent()
    Case #PB_EventCloseWindow
      Break
    Case #PB_EventGadget
      Select EventGadgetID()
      EndSelect
    Case #WM_TIMER
      If EventwParam() = 1
        t.f=(ElapsedMilliseconds()-StartTime)/1000.0
        SetGadgetText(0,"temps de connexion : "+StrF(t,1)+" sec.")
      EndIf
  EndSelect
ForEver

KillTimer_(WindowID(0),1)

Publié : mer. 01/mars/2006 21:12
par Flype
Ou comme çà ? :D

Code : Tout sélectionner

FontID0 = LoadFont(0, "Comic Sans MS", 10, #PB_Font_Bold | #PB_Font_Italic)

If OpenWindow(0, 216, 0, 240, 120,  #PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_ScreenCentered , "exemple")
  If CreateGadgetList(WindowID(0))
    TextGadget(0, 5, 50, 230, 20,"")
    SetGadgetFont(0,FontID0)
  EndIf
EndIf

StartTimer = ElapsedMilliseconds()

Repeat
  Select WindowEvent()
    Case #PB_EventCloseWindow
      Break
    Case #PB_EventGadget
      Select EventGadgetID()
      EndSelect
  EndSelect
  If ( ElapsedMilliseconds() - Timer ) > 100
    Timer = ElapsedMilliseconds()
    now.f = (Timer - StartTimer)/1000.0
    SetGadgetText(0,"temps de connexion : "+StrF(now,1)+" sec.")
  Else
    Delay(1)
  EndIf
ForEver

Publié : mer. 01/mars/2006 21:15
par venom
exelent. :D

cool merci flype de ta reponse bonne et rapide


@++

Publié : mer. 01/mars/2006 21:17
par Flype
Allez encore une autre ? :D

Code : Tout sélectionner

Procedure myTimer(gadget.l)
  StartTimer.l = ElapsedMilliseconds()
  Repeat
    SetGadgetText(gadget,"temps de connexion : "+StrF(((ElapsedMilliseconds()-StartTimer)/1000.0),1)+" sec.")
    Delay(100)
  ForEver
EndProcedure

FontID0 = LoadFont(0, "Comic Sans MS", 10, #PB_Font_Bold | #PB_Font_Italic)

If OpenWindow(0, 216, 0, 240, 120, #PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_ScreenCentered , "exemple")
  If CreateGadgetList(WindowID(0))
    TextGadget(0, 5, 50, 230, 20, "")
    SetGadgetFont(0,FontID0)
  EndIf
EndIf

CreateThread(@myTimer(),0)

Repeat
  Select WaitWindowEvent()
    Case #PB_EventCloseWindow: Break
  EndSelect
ForEver

Publié : mer. 01/mars/2006 21:40
par Droopy
On peut aussi gérer le Timer en tant que Procédure/Timer

Code : Tout sélectionner

#Window_0=0 
#Text=0 

Procedure TpsCnxion()
  Static Debut
  If Debut=0 : Debut= Date() : EndIf
  SetGadgetText(#Text,FormatDate("%hhh %ii'' %ss'",Date()-Debut))
EndProcedure

OpenWindow(#Window_0, 0, 0, 240, 40,  #PB_Window_SystemMenu |#PB_Window_ScreenCentered , "Connexion depuis :") 
CreateGadgetList(WindowID()) 
TextGadget(#Text, 10, 10, 220, 20, "",#PB_Text_Center) 
settimer_(WindowID(),0,100,@TpsCnxion())

Repeat 
  event = WaitWindowEvent() 
Until event = #PB_EventCloseWindow