Page 1 of 1

Bug or Not : AddWindowTimer + EventWindow()

Posted: Thu May 09, 2019 4:32 am
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?

Re: Bug or Not : AddWindowTimer + EventWindow()

Posted: Thu May 09, 2019 7:01 am
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