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 :
Normal
Maximized
- with native title bar:
Normal
Maximized
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
ShowWindow (hwnd, SW_SHOWMAXIMIZED);
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(),
boundsCopy.getY(),
boundsCopy.getWidth(),
boundsCopy.getHeight(),
false);
}
if (hasTitleBar())
ShowWindow (hwnd, SW_SHOWNORMAL);
}
else
{
if (hasTitleBar())
{
ShowWindow (hwnd, SW_SHOWMAXIMIZED);
#ifdef MY_MODIFICATIONS
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 - winInfo.rcWindow.top;
// this assertion fails if the position is incorrect !!
jassert (winInfo.rcWindow.left == -long(winInfo.cxWindowBorders)
&& winInfo.rcWindow.top == -long(winInfo.cyWindowBorders));
if(!(winInfo.rcWindow.left == -long(winInfo.cxWindowBorders)
&& winInfo.rcWindow.top == -long(winInfo.cyWindowBorders)))
MoveWindow (hwnd, -int(winInfo.cxWindowBorders),
-int(winInfo.cyWindowBorders), w, h, true);
}
#endif //MY_MODIFICATIONS
}
else
SendMessage (hwnd, WM_SETTINGCHANGE, 0, 0);
}
if (! deletionChecker.hasBeenDeleted())
handleMovedOrResized();
}
}
I found nothing about such a bug in Vista…
Any idea about what’s going wrong???
Thanx in advance !!!