DocumentWindow getWindowStateAsString()


#1

I save my window state with this, and i restore it. As long as the window is not maximized (using the maximize button and using the native titlebar) i can use the restoreWindowStateFromString, but once i have the window maximised, then exit and then re-launch and do restoreWindowStateFromString the window moves to high, the native titlebar is off the screen on the top. This is the string that gets saved and is used for restoring

i don’t know if “fs” means fullscreen, but if that’s the case maximized does not mean fullscreen, theese are two different things.


#2

Is this windows, mac? Does your window use a native title bar?


#3

no it’s windows7 x64 and yes using native titlebar.


#4

Well, I just tried this in the juce demo:

[code] void initialise (const String& /commandLine/)
{
#if JUCE_IPHONE
theMainWindow.setVisible (true);
theMainWindow.setFullScreen (true);
#else
// theMainWindow.centreWithSize (700, 600);

    theMainWindow.setUsingNativeTitleBar (true);
    theMainWindow.restoreWindowStateFromString ("fs 0 30 1680 1010");
    theMainWindow.setVisible (true);
  #endif[/code]

and it seemed to do the right thing to me. Can you give me some code that reproduces the problem?


#5

i use that in a standalone wrapper for plugins

in the ctor of the main document window

JUCE_TRY
    {
        filter = createPluginFilter();

        if (filter != 0)
        {
            filter->setPlayConfigDetails (2, 2, 44100, 512);
			MemoryBlock data = GETM(Config::Global, T("filterState"));
            filter->setStateInformation (data.getData(), data.getSize());
                
			setContentComponent (filter->createEditorIfNeeded(), true, true);

			if (GETS(Config::Windows, getName()) != String::empty)
			{
				L(GETS(Config::Windows, getName()));
				restoreWindowStateFromString (GETS(Config::Windows, getName()));
			}
			else
			{
				centreWithSize (600,600);
			}
        }
    }

this prints to the log if the last state was a maximized window

fs 418 208 844 645

in the destructor

if (filter != 0)
    {
        MemoryBlock data;
        filter->getStateInformation (data);
		SET (Config::Global, "filterState", data);
		SET (Config::Windows, getName(), getWindowStateAsString());
		L(getWindowStateAsString());
	}
    deleteFilter();

the result is a window that looks like this (this is the full screenshot from the screen nothing is cut, you will see what’s wrong) http://bayimg.com/FaDaMaadG

the weird thing is when i click on the taskbar button 3time (bring it to front bring it to back then bring it to front again), it comes back as a normal window the titlebar is visible, however it’s not maximized like so http://bayimg.com/FADaOAADG


#6

It looks to me like the window hasn’t got a native titlebar at the time when you restore its size… Perhaps you’re calling setUsesNativeTitlebar (true) after you’ve already restored its size?


#7

i tried both, before and after, same result


#8

Maybe give me some code I can apply to the demo app that reproduces this… I can’t see what you’re doing that would make it go wrong.


#9

well it’s a bit my fault but not all, i was working around the issue where when you start a juce application with a native titlebar it does not go to front on start you need to click it
so i was creating the window, restoring it from the string but after that setting it visible and adding it to desktop.

MyWindow::MyWindow : DocumentWindow (title, backgroundColour, DocumentWindow::allButtons, false)

if i do it the normal way it works.

MyWindow::MyWindow : DocumentWindow (title, backgroundColour, DocumentWindow::allButtons, true)

#10

Ah, right. Because until it’s actually on the screen and visible, it can’t have a native title bar, so the resizing won’t be able to take that into account when positioning it.


#11

i noticed that when i maximize the window on the second monitor, when i restore it, it’s moved to the primary monitor (the size is saved).


#12

ok… never noticed that before, I’ll have a go.


#13

it’s weird (i’m at the tip) if a window is stretched over two monitors (starts at one ends at the other) once it closed and the re-opened, it’s move to the monitor that it occupies the most (if it’s mostly on the left one after the restore it’s only on the left one and the other way around).

i think it’s important to say i’m on windows7 with NVidia drivers, i know that ATI does it’s multi monitor thing in some different way on XP don’t know how it’s done on Vista/7

aaand :slight_smile: it’s even more important to say i have 3 graphics cards, one disabled (Matrox internal onboard), and two NVidia geforce’s each monitor is connected to a different card.


#14

That doesn’t sound particularly strange, because when it makes it full-screen, it just makes it fill the monitor that contains the centre point of the component.


#15

yes but it’s not fullscreem, here are two screens before and after.


#16

Ok… I’ll have a look, though I run Win7 in a VM so not sure if I’ll be able to reproduce that myself.


#17

i think vmware has multiple display support, don’t know about parallels or virtualbox.