Bug or Not : AddWindowTimer + EventWindow()

Just starting out? Need help? Post your questions and find answers here.
Stefou
User
User
Posts: 19
Joined: Thu May 29, 2008 8:40 am

Bug or Not : AddWindowTimer + EventWindow()

Post by Stefou »

Hello everybody! 8)

I hope everything is fine for you and I thank you for reading me.

Here is a first code that works correctly:
- if I click on window 0, I have events on window 0
- if I click on window 1, I have events on the window 1

Code: Select all

If OpenWindow(0, 0, 0, 300, 600, "fenetre 0", #PB_Window_SystemMenu )
  
  OpenWindow(1, 310, 0, 300, 600, "fenetre 1", #PB_Window_SystemMenu,WindowID(0) )

  Repeat 
    event= WaitWindowEvent() 
    
    If event<>0 And event<>13110 And event<>275 ;retire quelques évenement commun
      Debug "Evenement PRINC : |"+EventWindow()+" | "+event
    EndIf
  
  Until event= #PB_Event_CloseWindow
EndIf

Problems happen when you install a timer:

Code: Select all

If OpenWindow(0, 0, 0, 300, 600, "fenetre 0", #PB_Window_SystemMenu )
  
  OpenWindow(1, 310, 0, 300, 600, "fenetre 1", #PB_Window_SystemMenu,WindowID(0) )
  AddWindowTimer(0,1,100)
  Repeat 
    event= WaitWindowEvent() 
    
    If event<>0 And event<>13110 And event<>275 ;retire quelques évenement commun
      Debug "Evenement PRINC : |"+EventWindow()+" | "+event
    EndIf
    
  Until event= #PB_Event_CloseWindow
EndIf
One realizes that by clicking in the window 1, events like 512,513,514 are generated with as ID the window 0 which posed me problem and does not seem to me desirable ...

What do you think?
User avatar
mk-soft
Always Here
Always Here
Posts: 6257
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Bug or Not : AddWindowTimer + EventWindow()

Post by mk-soft »

No Bug...

Windows always delivers a lot of events.
So also Timer Events.

Always use the PB constants and filter the events correctly.

Code: Select all

If OpenWindow(0, 0, 0, 300, 600, "fenetre 0", #PB_Window_SystemMenu )
  
  OpenWindow(1, 310, 0, 300, 600, "fenetre 1", #PB_Window_SystemMenu,WindowID(0) )
  AddWindowTimer(0,1,1000)
  Repeat 
    event= WaitWindowEvent() 
    Select Event
      Case #PB_Event_CloseWindow
        Break
      Case #PB_Event_Timer
        If EventTimer() = 1
          Debug "Timer"
        EndIf
    EndSelect
  ForEver
EndIf
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Post Reply