#PB_Event_ActivateAppWindow & #PB_Event_DeactivateAppWindow

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
mestnyi
Addict
Addict
Posts: 1098
Joined: Mon Nov 25, 2013 6:41 am

#PB_Event_ActivateAppWindow & #PB_Event_DeactivateAppWindow

Post 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
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: #PB_Event_ActivateAppWindow & #PB_Event_DeactivateAppWin

Post by IdeasVacuum »

Re-inventing the wheel? :?
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
mestnyi
Addict
Addict
Posts: 1098
Joined: Mon Nov 25, 2013 6:41 am

Re: #PB_Event_ActivateAppWindow & #PB_Event_DeactivateAppWin

Post by mestnyi »

Re-inventing the wheel? :?
Why? :)
User avatar
TI-994A
Addict
Addict
Posts: 2704
Joined: Sat Feb 19, 2011 3:47 am
Location: Singapore
Contact:

Re: #PB_Event_ActivateAppWindow & #PB_Event_DeactivateAppWin

Post by TI-994A »

mestnyi wrote:Why? :)
Hi mestnyi. Pardon my ignorance, but what purpose would this serve? :)
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel :D
mestnyi
Addict
Addict
Posts: 1098
Joined: Mon Nov 25, 2013 6:41 am

Re: #PB_Event_ActivateAppWindow & #PB_Event_DeactivateAppWin

Post 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
Post Reply