Page 1 of 1
[Implemented] IsWindowActive()
Posted: Thu Sep 02, 2004 12:26 pm
by nco2k
IsScreenActive() is a very nice and usefull command, so there should be a IsWindowActive() command aswell.
c ya,
nco2k
Posted: Thu Sep 02, 2004 7:18 pm
by GreenGiant
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:
Code: Select all
If GetForegroundWindow_()=WindowID()
Debug "Is active"
Else
Debug "Isn't active"
EndIf
(only for windows though)
Posted: Fri Sep 03, 2004 12:08 am
by nco2k
sure, but its stil winapi... i am getting tired of always using it, for almost every single thing.
c ya,
nco2k
Posted: Fri Sep 03, 2004 1:51 pm
by GreenGiant
sure, but its stil winapi... i am getting tired of always using it, for almost every single thing
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.
Posted: Fri Sep 03, 2004 1:55 pm
by PB
> 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.
Posted: Fri Sep 03, 2004 2:48 pm
by nco2k
@GreenGiant
of course... many commands use the api under the hood, but a purebasic command does the dirty work for you and you dont need to worry about cross-platform compatibility.
@PB
yep its because of the cross-platform compatibility.
c ya,
nco2k
Posted: Sat Sep 04, 2004 7:12 am
by PB
> yep its because of the cross-platform compatibility.
Fair enough then!

Posted: Sat Sep 04, 2004 2:11 pm
by GreenGiant
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.