Sign in to follow this  

how to detect if an allegro window is inactive

This topic is 2813 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am making a windowed game in allegro in the Windows OS that has sounds. When the window loses focus, like the user clicks off the window, the sounds freeze because the window is no longer the focus. Does anyone know if there is a way in allegro to detect when the window loses focus like that so i can pause the sounds. I know allegro has windows OS specific functions but am not sure how i would use these to do this. Thanks.

Share this post


Link to post
Share on other sites
i think it might work. To get it to work with sound i was thinking of having a int variable that would be set to 1 if the screen is in focus and 0 if it isn't and then just put an if statement wrapper around the code that plays the sounds to check to make sure the screen is in focus before playing the sound, or maybe i could use that callback function to stop play when the window loses focus and resume play when it comes into focus again.


Thanks.

Share this post


Link to post
Share on other sites
that didn't really work, i tried both the regular and the callback version. Now that i think about it, music in full screen games freezes too when the window loses focus or something, so its probably not that straight forwrad to do this.

Thanks for the help.

Share this post


Link to post
Share on other sites

This topic is 2813 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this