VISTA: maximizing a window with native title bar fails


Hi Jules !

I’ve experienced a strange bug on Vista…
When you try to maximize a window with native title bar, it sometimes fails :
the window’s got the right size but its position is incorrect…

This never happens with a juce title bar.

Here are a few screenshots from the juce demo to illustrate :

  • with juce title bar :



  • with native title bar:



Note that I didn’t move the window after having switched to native title bar.

In fact this bug depends on the window’s size and position…

If I move or resize the window it may keep on failing or not.
When it fails, if I switch to juce title bar and then back to native one, it stops failing (but can fail again if I move or resize the window…)

I had look at win32 windowing code (juce_win32_Windowing.cpp) and i tried to force window’s position on maximizing but it doesn’t really work (the position is correct but the title bar hasn’t got the right height anymore…)

The problem is that after calling

the position is incorrect …

Here is my test code

void setFullScreen (bool shouldBeFullScreen)
        setMinimised (false);

        if (fullScreen != shouldBeFullScreen)
            fullScreen = shouldBeFullScreen;
            const ComponentDeletionWatcher deletionChecker (component);

            if (! fullScreen)
                const Rectangle boundsCopy (lastNonFullscreenBounds);

                if (! boundsCopy.isEmpty())
                    setBounds (boundsCopy.getX(),

                if (hasTitleBar())
                    ShowWindow (hwnd, SW_SHOWNORMAL);
                if (hasTitleBar())
                    ShowWindow (hwnd, SW_SHOWMAXIMIZED);
                    if (SystemStats::getOperatingSystemType() == SystemStats::WinVista)
                        WINDOWINFO winInfo;
                        GetWindowInfo (hwnd, &winInfo);
                        const int w = winInfo.rcWindow.right - winInfo.rcWindow.left;
                        const int h = winInfo.rcWindow.bottom -;

                       // this assertion fails if the position is incorrect !!
                        jassert (winInfo.rcWindow.left == -long(winInfo.cxWindowBorders) 
                                 && == -long(winInfo.cyWindowBorders));

                        if(!(winInfo.rcWindow.left == -long(winInfo.cxWindowBorders) 
                             && == -long(winInfo.cyWindowBorders)))
                            MoveWindow (hwnd, -int(winInfo.cxWindowBorders), 
                                        -int(winInfo.cyWindowBorders), w, h, true);
                    SendMessage (hwnd, WM_SETTINGCHANGE, 0, 0);

            if (! deletionChecker.hasBeenDeleted())

I found nothing about such a bug in Vista…
Any idea about what’s going wrong???

Thanx in advance !!!


Wow. That’s a strange one. Is it a random position?

I do have a vista install now, so I’ll try it myself shortly…


Yes it is.

I’ve experienced this many times (to be sure I was not hallucinating :wink: ) and it can happen anywhere on the screen !

Yet, it seems the “incorrect maximized position” depends on the initial position (but they are not the same !).
The more the top of the window is near the bottom of the screen, the more the top of the incorrectly maximized window is near the bottom of the screen.

Don’t know if it can be a clue …

Nice to know that you finally have a Vista install :smiley:



Sorry to dig out this issue, but it seems to not have been solved entirely.

- I have a window with a native title bar which is set fullscreen at its creation.

- If the system has a magnify factor of 1 (100%) then it is OK.

- But if the system has a magnify factor other than 1 (1,25 or 1,5 on Windows) then the window is wrongly positionned.

Do you have any solution ?


The original post was about Windows Vista - what version of Windows are you actually using?