GM_setSuspendAppCallback

Sets the suspend app callback function

Declaration

void MGLAPI GM_setSuspendAppCallback(
    MGL_suspend_cb_t saveState)

Prototype In

gm/gm.h

Description

This function sets the suspend app callback function for your Game Framework game and is called by the Game Framework whenever the user switches away from your game (suspends it, such as with Alt-Tab). The Game Framework registers a default suspend application callback with the MGL to do most of the handling for you. Note however that by default the Game Framework suspend app callback passes a return value of MGL_SUSPEND_APP back to the MGL which will suspend execution of your game until it has been restored. The Game Framework has code to automatically ensure that the draw callback is not called when the game is minimised and gets re-enabled when the game is restored again if you return a value of MGL_NO_SUSPEND_APP from your registered callback (this way you can continue to run networking code in the background to keep other network players running if the server is temporarily minimised).

You should register your own version of this function to handle extra things during suspend and restores such as suspending CD-Audio sound playback or other stuff not automatically handled by the underlying multi-media libraries. A typical suspend application callback might be coded as follows:

int _ASMAPI SuspendAppProc(MGLDC *dc,int flags)
{
    if (flags == MGL_DEACTIVATE) {
        // Disable CD-Audio
        // Do other disabling stuff
        return MGL_NO_SUSPEND_APP;
        }
    else if (flags == MGL_REACTIVATE) {
        // Re-enable CD-Audio
        // Do other re-enabling stuff
        return MGL_NO_SUSPEND_APP;
        }
}

See Also

GM_init, GM_setSuspendAppProc

Copyright © 2002 SciTech Software, Inc. Visit our web site at http://www.scitechsoft.com