Page 1 of 1

#PB_Event_ActivateAppWindow & #PB_Event_DeactivateAppWindow

Posted: Thu May 07, 2015 9:48 am
by mestnyi

Code: Select all

Global DeactivateApp

Enumeration #PB_Event_FirstCustomValue
  #PB_Event_ActivateAppWindow
  #PB_Event_DeactivateAppWindow
EndEnumeration

Procedure PB_Event_ActivateAppWindow()
  If DeactivateApp = #True :DeactivateApp = #False
    While WindowEvent() = #PB_Event_ActivateWindow :Wend
    PostEvent(#PB_Event_ActivateAppWindow, EventWindow(), -1)
  EndIf
EndProcedure

Procedure PB_Event_DeactivateAppWindow()
  If GetActiveWindow() =-1 :DeactivateApp = #True
    While WindowEvent() = #PB_Event_DeactivateWindow :Wend
    PostEvent(#PB_Event_DeactivateAppWindow, EventWindow(), -1)
  EndIf
EndProcedure
BindEvent(#PB_Event_ActivateWindow, @PB_Event_ActivateAppWindow())
BindEvent(#PB_Event_DeactivateWindow, @PB_Event_DeactivateAppWindow())

; -------------

OpenWindow(0,200,200,100,50,"test 1")
TextGadget(0,10,10,80,20,"")
OpenWindow(1,400,200,100,50,"test 2")
TextGadget(1,10,10,80,20,"")

Define Counter
Define ActivateAppWindow
Repeat
  Event = WindowEvent()
  Window = EventWindow()
  Select Event 
    Case #PB_Event_ActivateAppWindow
      Debug "#PB_Event_ActivateApp "
     ActivateAppWindow = #True
     
    Case #PB_Event_ActivateWindow
      Debug "#PB_Event_Activate "
      
    Case #PB_Event_DeactivateAppWindow
      Debug "#PB_Event_DeactivateApp "
     ActivateAppWindow = #False
      
    Case #PB_Event_DeactivateWindow
      Debug "#PB_Event_Deactivate "
      
    Default
      Delay(10)
      If ActivateAppWindow = #True
        Counter+1
        SetGadgetText(0,Str(Counter))
      EndIf
  EndSelect
Until Event=#PB_Event_CloseWindow

Re: #PB_Event_ActivateAppWindow & #PB_Event_DeactivateAppWin

Posted: Thu May 07, 2015 11:23 am
by IdeasVacuum
Re-inventing the wheel? :?

Re: #PB_Event_ActivateAppWindow & #PB_Event_DeactivateAppWin

Posted: Thu May 07, 2015 1:47 pm
by mestnyi
Re-inventing the wheel? :?
Why? :)

Re: #PB_Event_ActivateAppWindow & #PB_Event_DeactivateAppWin

Posted: Thu May 07, 2015 3:07 pm
by TI-994A
mestnyi wrote:Why? :)
Hi mestnyi. Pardon my ignorance, but what purpose would this serve? :)

Re: #PB_Event_ActivateAppWindow & #PB_Event_DeactivateAppWin

Posted: Thu May 07, 2015 4:41 pm
by mestnyi
but what purpose would this serve? :)
The purpose can be found, the main thing that was possible. :)
Here's an example
http://forums.purebasic.com/english/vie ... 75fba5c0a3