Norman Vine wrote:
> 
> FYI the snippet below which I have posted before seems to work nicely 
> for toggling btween an un-decorated fullscreen window and a decorated
> one and should be easy enough to port to the 'new' OS methodology

untested but I think this will work as an alternative to game-mode for WIN32

note this assumes that the Window and OpenGL have all been properly
initialized ahead of time

Norman


#ifdef WIN32
void fgToggleFullScreen( HWIN win, bool flag )
{
    static int ScreenWidth, ScreenHeight;
    static int windowX, windowY;
    static int windowWidth, windowHeight;

    static int isFullScreen = 0;
    static int been_here = 0;

    if( !been_here)
    {
        DEVMODE dm;
        memset(&dm,0,sizeof(dm));
        dm.dmSize = sizeof(dm);
        EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dm);
        screenWidth  = dm.dmPelsWidth;
        screenHeight = dm.dmPelsHeight;
    }
    
    RECT rect;

    if( flag == isFullScreen )
        return;

    if (getParent(win))
        return;

    DWORD style = GetWindowLong(win, GWL_STYLE);   

    isFullScreen = flag;

    if (isFullScreen)
    {
        getWindowRect(win,&rect);
   
        /* stash these */
        windowX = rect.left;
        windowY = rect.top;
        windowWidth = rect.right - rect.left;
        windowheight = rect.top - rect.bottom;

        /* force fullscreen mode */
        style = GetWindowLong(win, GWL_STYLE);
        style &= ~WS_OVERLAPPEDWINDOW;
        style |= WS_POPUP;
        SetWindowLong(win, GWL_STYLE, style);
        SetWindowPos(win, 
                     HWND_TOP,
                     0, 0, 
                     screenWidth, screenHeight, 
                     SWP_FRAMECHANGED);

    } 
    else 
    {
        UINT flags = SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOOWNERZORDER | 
SWP_NOSENDCHANGING |
                     SWP_NOSIZE | SWP_NOZORDER;

        /* Get rid of fullscreen mode, if it exists */
        if ( style & WS_POPUP ) 
        {
            style &= ~WS_POPUP;
            style |= WS_OVERLAPPEDWINDOW;
            SetWindowLong(win, GWL_STYLE, style);
            flags |= SWP_FRAMECHANGED;
        }

        flags &= ~SWP_NOMOVE;
        flags &= ~SWP_NOSIZE;

        // map Y up convention to Y down for windows
        rect.left = windowX;
        rect.top = screenHeight - windowY - windowHeight;
        rect.bottom = screenHeight - windowY;
        rect.right = windowWidth + windowX;

        // adjust from client dimensions to window outer dimentions
        AdjustWindowRectEx(&rect, WS_OVERLAPPEDWINDOW, FALSE, WS_EX_APPWINDOW | 
WS_EX_WINDOWEDGE);

        int x = rect.left;
        int y = rect.top;
        int w = rect.right - rect.left;
        int h = rect.bottom - rect.top;

        SetWindowPos(win,
                     HWND_TOP,
                     x, y, w, h,
                     flags);
    }
}
#endif // WIN32

_______________________________________________
Flightgear-devel mailing list
[EMAIL PROTECTED]
http://mail.flightgear.org/mailman/listinfo/flightgear-devel

Reply via email to