IsScreenActive() is a very nice and usefull command, so there should be a IsWindowActive() command aswell.
c ya,
nco2k
[Implemented] IsWindowActive()
-
- Enthusiast
- Posts: 252
- Joined: Fri Feb 20, 2004 5:43 pm
I think the point of the IsScreenActive command is so that people can pause their games if the user alt-tabs out of their program. However I think to do the same thing with a window you could just do something like this: (only for windows though)
Code: Select all
If GetForegroundWindow_()=WindowID()
Debug "Is active"
Else
Debug "Isn't active"
EndIf
-
- Enthusiast
- Posts: 252
- Joined: Fri Feb 20, 2004 5:43 pm
My guess would be that the IsScreenActive() command probably uses the api, just under the hood. And I think any introduced IsWindowActive() command would probably just be wrapping similar api code to that which I posted. I don't see the problem with just using the api code.sure, but its stil winapi... i am getting tired of always using it, for almost every single thing
> its stil winapi... i am getting tired of always using it
Why? If your app isn't cross-platform, then what's the problem? It's not like
you need to declare them first (like Visual Basic) -- they're as simple and easy
to use as any other Basic command.
Why? If your app isn't cross-platform, then what's the problem? It's not like
you need to declare them first (like Visual Basic) -- they're as simple and easy
to use as any other Basic command.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.
-
- Enthusiast
- Posts: 252
- Joined: Fri Feb 20, 2004 5:43 pm
I'm pretty sure that in Windows there's a WindowEvent() event that signifies that your window has lost focus (only a number, not a defined constant as far as I know). If that exists in the linux version too then that would probably be a better way to do it. I think that would fit in better to the event-driven loop most apps use.
With a screen you are generally running through your loop 60 times or so a second, so if you check for the screen being active each loop you can respond pretty much instant instantly when it's deactivated. But in an event-driven loop, you'd only find out it had lost focus when a window event occured, and I doubt you get many when your window isn't active. Probably the only one you'd get would be one that signalled your window gaining/losing focus
. So I think a defined #PB_LostFocus and a #PB_GainedFocus constant for use with WaitWindowEvent would be more useful.
With a screen you are generally running through your loop 60 times or so a second, so if you check for the screen being active each loop you can respond pretty much instant instantly when it's deactivated. But in an event-driven loop, you'd only find out it had lost focus when a window event occured, and I doubt you get many when your window isn't active. Probably the only one you'd get would be one that signalled your window gaining/losing focus
