Can I stop my PB app becoming the active window when it starts running?
OpenWindow(0, 0, 0, 200, 280, "", #PB_Window_SystemMenu)
I need the window to be visible but not to be the active window.
Tried #PB_Window_NoActivate but that has not done the trick.
Prevent my app becoming the active window when it starts
Re: Prevent my app becoming the active window when it starts
The #PB_Window_NoActivate directive seems to work (PureBasic 5.70 LTS x64 on Windows 8.1 Professional):BlindMan wrote:Can I stop my PB app becoming the active window when it starts running?
...I need the window to be visible but not to be the active window.
Tried #PB_Window_NoActivate but that has not done the trick.
Code: Select all
wFlags = #PB_Window_SystemMenu |
#PB_Window_ScreenCentered |
#PB_Window_NoActivate
OpenWindow(0, 0, 0, 300, 200, "Non-Active Window", wFlags)
While WaitWindowEvent() ! #PB_Event_CloseWindow : Wend
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
Re: Prevent my app becoming the active window when it starts
Sorry, my mistake.
I forgot to remove a call to SetActiveGadget().
#PB_Window_NoActivate now working as expected.
Just out of interest, if the window becomes active after it has been opened, what is the best way to reapply #PB_Window_NoActivate ?
I forgot to remove a call to SetActiveGadget().
#PB_Window_NoActivate now working as expected.
Just out of interest, if the window becomes active after it has been opened, what is the best way to reapply #PB_Window_NoActivate ?
Re: Prevent my app becoming the active window when it starts
Technically, an active window becomes inactive only when another window becomes active. The window loses focus when another window receives focus. So, the best way to de-activate a window would be to set the focus on the desktop.BlindMan wrote:...what is the best way to reapply #PB_Window_NoActivate ?
Code: Select all
wFlags = #PB_Window_SystemMenu | #PB_Window_ScreenCentered
OpenWindow(0, 0, 0, 300, 200, "WINDOW HAS FOCUS", wFlags)
ButtonGadget(0, 10, 140, 280, 50, "REMOVE FOCUS")
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
appQuit = 1
Case #PB_Event_ActivateWindow
SetWindowTitle(0, "WINDOW HAS FOCUS")
Case #PB_Event_DeactivateWindow
SetWindowTitle(0, "WINDOW LOST FOCUS")
Case #PB_Event_Gadget
Select EventGadget()
Case 0
SetForegroundWindow_(GetDesktopWindow_())
EndSelect
EndSelect
Until appQuit = 1
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