Fensterinhalt aktuallisieren

Anfängerfragen zum Programmieren mit PureBasic.
Benutzeravatar
The_Dark_Zim-.-
Beiträge: 372
Registriert: 18.03.2008 16:53

Fensterinhalt aktuallisieren

Beitrag von The_Dark_Zim-.- »

Hey Ho
Ich hab ein kleines Problem mit der Aktuallisierung meines Fensters.
Ich änder jede sec. einen TextGadget(), der ändert sich aber nur wenn ich etwas in dem Fenster mache, z.B. Mausbewege.

Woran liegt das ? An WaitWindowEvent() ?
Wie kann ich das ändern ?

Gruß Zim
PB: 5.xx LTS x86/x64 | WIN: 10 Pro x64, Linux Mint x64
Benutzeravatar
ts-soft
Beiträge: 22292
Registriert: 08.09.2004 00:57
Computerausstattung: Mainboard: MSI 970A-G43
CPU: AMD FX-6300 Six-Core Processor
GraKa: GeForce GTX 750 Ti, 2 GB
Memory: 16 GB DDR3-1600 - Dual Channel
Wohnort: Berlin

Beitrag von ts-soft »

> Woran liegt das ?
An Deinem Code
> Wie kann ich das ändern ?
Woher sollen wir das Wissen, ohne Code?

Kleiner Scherzkeks

Mit Deinem EventLoop hat es mit Sicherheit zu tun.
PureBasic 5.73 LTS | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Nutella hat nur sehr wenig Vitamine. Deswegen muss man davon relativ viel essen.
Bild
Benutzeravatar
RSBasic
Admin
Beiträge: 8047
Registriert: 05.10.2006 18:55
Wohnort: Gernsbach
Kontaktdaten:

Beitrag von RSBasic »

@The_Dark_Zim-.-
Meinst du etwa dieses "Problem"?

Code: Alles auswählen

EnableExplicit

Define a

If OpenWindow(0,0,0,500,250,"Window",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
  TextGadget(1,10,10,100,20,"",0)
  
Repeat
  a+1
  SetGadgetText(1,Str(a))
Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Falls ja, es liegt am WaitWindowEvent([TimeOut]) und kannst mit...

Code: Alles auswählen

EnableExplicit

Define a

If OpenWindow(0,0,0,500,250,"Window",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
  TextGadget(1,10,10,100,20,"",0)
  
Repeat
  a+1
  SetGadgetText(1,Str(a))
Until WaitWindowEvent(10) = #PB_Event_CloseWindow
EndIf
beheben.
Zuletzt geändert von RSBasic am 12.08.2009 20:18, insgesamt 1-mal geändert.
Aus privaten Gründen habe ich leider nicht mehr so viel Zeit wie früher. Bitte habt Verständnis dafür.
Bild
Bild
Benutzeravatar
The_Dark_Zim-.-
Beiträge: 372
Registriert: 18.03.2008 16:53

Beitrag von The_Dark_Zim-.- »

Sry, ich dachte mir ihr kennt das schon :P

Naja mein Fehler :roll:
Hier der Code:

Code: Alles auswählen

Enumeration
  #Window_0
  #Text_0
  #Button_0
  #Button_1
  #Text_1
  #StatusBar_0
  
  #Window_1
  #Button_2
  #Button_3
EndEnumeration

Global Project$
Global ExitQuestion
Global SekundeNew
Global SekundeOld
Global Minute
Global Stunde
Global Sekunde
Global FontID1
Global FontID2

FontID1 = LoadFont(1, "Arial Black", 72, #PB_Font_Bold)
FontID2= LoadFont(2, "Arial Black", 30, #PB_Font_Bold)

Procedure Open_Window_0()
  If OpenWindow(#Window_0, 342, 277, 600, 300, "Time-Manager",  #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered)
    If CreateStatusBar(#StatusBar_0, WindowID(#Window_0))
      EndIf

      If CreateGadgetList(WindowID(#Window_0))
        TextGadget(#Text_0, 65, 30, 460, 145, "")
        SetGadgetFont(#Text_0, FontID1)
        ButtonGadget(#Button_0, 75, 215, 110, 30, "Start-Stop")
        ButtonGadget(#Button_1, 405, 215, 110, 30, "Project")
        TextGadget(#Text_1, 195, 200, 195, 50, "")
        SetGadgetFont(#Text_1, FontID2)
      EndIf
    EndIf
EndProcedure

Procedure Project()
Project$ =""
  If OpenWindow(#Window_1, 317, 389, 248, 76, "Project",  #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar )
    If CreateGadgetList(WindowID(#Window_1))
      ButtonGadget(#Button_3, 135, 25, 95, 35, "Erstellen")
      ButtonGadget(#Button_2, 15, 25, 95, 35, "Öffnen")
      
    EndIf
  EndIf

Repeat
  
  Event = WaitWindowEvent()
  WindowID = EventWindow()
  GadgetID = EventGadget()
  EventType = EventType()

  If Event = #PB_Event_Gadget
    
    If GadgetID = #Button_2
      Project$ = OpenFileRequester("Bitte Project wählen!","","Project (*.Pjt)|*.Pjt",0)
     If Project$ = ""
     Else
      OpenFile(0,Project$)
      ExitQuestion = 1
     EndIf
    ElseIf GadgetID = #Button_3
      Project$ = SaveFileRequester("Bitte Speicherort und Name wählen!","New Project.Pjt","Project (*.Pjt)|*.Pjt",0)
     If Project$
      CreateFile(0,Project$)
      ExitQuestion = 1
     EndIf
    EndIf
    
  EndIf
  
Until ExitQuestion = 1
 CloseWindow(#window_1)
 
 StatusBarText(#StatusBar_0, 0, "Offenes Project: "+ GetFilePart(Project$))
 
ExitQuestion = 0
EndProcedure

Procedure Time()

Sekunde$ = FormatDate("%ss", Date())

SekundeNew = (Val(Sekunde$))

If SekundeNew <> SekundeOld
 Sekunde +1
  If Sekunde = 60
   Sekunde = 0
  EndIf

 If Sekunde = 0
  Minute +1
   If Minute = 60
    Minute = 0
    Stunde + 1
   EndIf
 EndIf
  SetGadgetText(#Text_0,Str(Stunde)+":"+Str(Minute)+":"+Str(Sekunde))
  SetGadgetText(#Text_1,FormatDate("%hh:%ii:%ss", Date()))
EndIf

SekundeOld = SekundeNew
EndProcedure

Open_Window_0()

Repeat

If StartStop = 1
 Time()
ElseIf StartStop = 2
 StartStop = 0
EndIf

  Event = WaitWindowEvent()
  WindowID = EventWindow()
  GadgetID = EventGadget()
  EventType = EventType()

  If Event = #PB_Event_Gadget
    
    If GadgetID = #Button_0
     StartStop +1
    ElseIf GadgetID = #Button_1
     Project()
    EndIf
    
  EndIf
  
Until Event = #PB_Event_CloseWindow

End
Gruß Zim
PB: 5.xx LTS x86/x64 | WIN: 10 Pro x64, Linux Mint x64
Benutzeravatar
RSBasic
Admin
Beiträge: 8047
Registriert: 05.10.2006 18:55
Wohnort: Gernsbach
Kontaktdaten:

Beitrag von RSBasic »

Code: Alles auswählen

Enumeration
  #Window_0
  #Text_0
  #Button_0
  #Button_1
  #Text_1
  #StatusBar_0
 
  #Window_1
  #Button_2
  #Button_3
EndEnumeration

Global Project$
Global ExitQuestion
Global SekundeNew
Global SekundeOld
Global Minute
Global Stunde
Global Sekunde
Global FontID1
Global FontID2

FontID1 = LoadFont(1, "Arial Black", 72, #PB_Font_Bold)
FontID2= LoadFont(2, "Arial Black", 30, #PB_Font_Bold)

Procedure Open_Window_0()
  If OpenWindow(#Window_0, 342, 277, 600, 300, "Time-Manager",  #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered)
    If CreateStatusBar(#StatusBar_0, WindowID(#Window_0))
      EndIf

      If CreateGadgetList(WindowID(#Window_0))
        TextGadget(#Text_0, 65, 30, 460, 145, "")
        SetGadgetFont(#Text_0, FontID1)
        ButtonGadget(#Button_0, 75, 215, 110, 30, "Start-Stop")
        ButtonGadget(#Button_1, 405, 215, 110, 30, "Project")
        TextGadget(#Text_1, 195, 200, 195, 50, "")
        SetGadgetFont(#Text_1, FontID2)
      EndIf
    EndIf
EndProcedure

Procedure Project()
Project$ =""
  If OpenWindow(#Window_1, 317, 389, 248, 76, "Project",  #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar )
    If CreateGadgetList(WindowID(#Window_1))
      ButtonGadget(#Button_3, 135, 25, 95, 35, "Erstellen")
      ButtonGadget(#Button_2, 15, 25, 95, 35, "Öffnen")
     
    EndIf
  EndIf

Repeat
 
  Event = WaitWindowEvent()
  WindowID = EventWindow()
  GadgetID = EventGadget()
  EventType = EventType()

  If Event = #PB_Event_Gadget
   
    If GadgetID = #Button_2
      Project$ = OpenFileRequester("Bitte Project wählen!","","Project (*.Pjt)|*.Pjt",0)
     If Project$ = ""
     Else
      OpenFile(0,Project$)
      ExitQuestion = 1
     EndIf
    ElseIf GadgetID = #Button_3
      Project$ = SaveFileRequester("Bitte Speicherort und Name wählen!","New Project.Pjt","Project (*.Pjt)|*.Pjt",0)
     If Project$
      CreateFile(0,Project$)
      ExitQuestion = 1
     EndIf
    EndIf
   
  EndIf
 
Until ExitQuestion = 1
 CloseWindow(#window_1)
 
 StatusBarText(#StatusBar_0, 0, "Offenes Project: "+ GetFilePart(Project$))
 
ExitQuestion = 0
EndProcedure

Procedure Time()

Sekunde$ = FormatDate("%ss", Date())

SekundeNew = (Val(Sekunde$))

If SekundeNew <> SekundeOld
 Sekunde +1
  If Sekunde = 60
   Sekunde = 0
  EndIf

 If Sekunde = 0
  Minute +1
   If Minute = 60
    Minute = 0
    Stunde + 1
   EndIf
 EndIf
  SetGadgetText(#Text_0,Str(Stunde)+":"+Str(Minute)+":"+Str(Sekunde))
  SetGadgetText(#Text_1,FormatDate("%hh:%ii:%ss", Date()))
EndIf

SekundeOld = SekundeNew
EndProcedure

Open_Window_0()

Repeat

If StartStop = 1
 Time()
ElseIf StartStop = 2
 StartStop = 0
EndIf

  Event = WaitWindowEvent(10)
  WindowID = EventWindow()
  GadgetID = EventGadget()
  EventType = EventType()

  If Event = #PB_Event_Gadget
   
    If GadgetID = #Button_0
     StartStop +1
    ElseIf GadgetID = #Button_1
     Project()
    EndIf
   
  EndIf
 
Until Event = #PB_Event_CloseWindow

End
Aus privaten Gründen habe ich leider nicht mehr so viel Zeit wie früher. Bitte habt Verständnis dafür.
Bild
Bild
Benutzeravatar
The_Dark_Zim-.-
Beiträge: 372
Registriert: 18.03.2008 16:53

Beitrag von The_Dark_Zim-.- »

:):):):)
Sweet geht THX RSBasic
PB: 5.xx LTS x86/x64 | WIN: 10 Pro x64, Linux Mint x64
Antworten