Restoring size and location of dialogs

I am working on an application where I want to open resizable dialogs the same size and at the location asthe previous time they were closed.  I currently do this in the destructor of the main component.

    int x=getScreenX();
    int y=getScreenY();
    int w=getParentWidth();
    int h=getParentHeight();


Then in main.cpp when creating the window I have this:

                vp->setSize(w,h+18); // vp is a viewport.

This works fine on windows 7, but on windows 2008, the size gets taller every time.  I think I should be able to set the position to (x,y) and the size to (w,h), but why doesn't this work?  The fact that I have these fudge numbers added indicates I am clearing getting the wrong size and position information, or setting it incorrectly.

I have the same problems with other dialogs opened from within this window.  Anyone know how I should be doing this?

Have you tried ResizableWindow::getWindowStateAsString and restoreWindowStateFromString?

I just tried get getWindowStateAsString but got the same results.  I did realize I was getting the size in the wrong destructor.  I was doing it in the dialog object attached to the window and it should have been in the window object.  So I was getting the size and location inside the window frame.  So I was able to fix all the dialogs except the main one.

The main window is created in main.cpp.  Looks like this:

    class MainWindow    : public DocumentWindow
        MainWindow()  : DocumentWindow ("MainWindow",

            MainContentComponent *mm = new MainContentComponent();
            Viewport *vp=new Viewport();


            vp->setSize (50+60*(10), 500);
            setContentOwned (vp, true);
            //centreWithSize (getWidth(), getHeight());
            setVisible (true);
            setResizable(true, true);





x,y,h,w are saved in the destructor of MainContentComponent with:

    int x=getScreenX();
    int y=getScreenY();
    int w=getParentWidth();
    int h=getParentHeight();

I have confirmed that the values retrieved here persisted, and are the same value when restoring the window in main.cpp.

If I change the w,y to getWidth/getHeight, I get the size of the viewport within the window, but I do not seem to be getting the actual size of the window no matter what I do.

how about collecting the values on `resize' rather than in the destructor. virtual method problems?