GetClientSize()

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
daggmano
In need of some credit
In need of some credit
Posts: 6
Joined: Tue May 03, 2005 10:46 pm
Contact:

GetClientSize()

Post by daggmano » Tue May 03, 2005 11:02 pm

I'm working on a program that uses splitters to, well, split up a main area into 4 blocks (each with a custom frame). When the application is resized, the vertical splitter should remain in the centre of the window, while the two horizontal splitters (one per side of the vertical splitter) should be set to 200 pixels above the bottom of the window. Code for resize is thus:

Code: Select all

void MainFrame::OnSize(wxSizeEvent &event)
{
    wxSize size;

    Layout();
    wxFrame::OnSize(event);

    if (m_pSpMain)
    {
        size = m_pSpMain->GetClientSize();
        m_pSpMain->SetSashPosition(size.GetWidth() / 2);
        m_pSpMain->UpdateSize();
		
        if (m_pSpPreview)
        {
            size = m_pSpPreview->GetClientSize();
            m_pSpPreview->SetSashPosition(size.GetHeight() - 200);
            m_pSpPreview->UpdateSize();
        }

        if (m_pSpProgram)
        {
            size = m_pSpProgram->GetClientSize();
            m_pSpProgram->SetSashPosition(size.GetHeight() - 200);
            m_pSpProgram->UpdateSize();
        }
    }
}
(I apologise for my forum n00b-ness - the indentation doesn't seem to have displayed properly in preview)

The problem I am having is that the value returned by GetClientSize() is not correct under Windows. Example: when normalising the application after being maximised, I will get a ClientSize which is 1 pixel smaller than the MAXIMISED size, not the final normalised size. When resizing a window manually (dragging with the mouse), GetClientSize() gets a size 1 pixel larger or smaller than the original size, NOT the final window size.

Strangely, the code works perfectly on Linux.

I am using wxWidgets 2.6.0, MinGW compiler.

Any ideas?

krysa
Experienced Solver
Experienced Solver
Posts: 71
Joined: Wed Feb 16, 2005 9:23 pm
Location: Lithuania

Re: GetClientSize()

Post by krysa » Tue May 03, 2005 11:16 pm

daggmano wrote:Any ideas?
I've had some unexpexted values from GetClientSize() too, but GetVirtualSize() worked in my case (doc's says it is prety much the same thing, but strangely - it worked differently, and i wasn't calling SetVirtualSize() anywhere in my code). Maybe it'll solve your problem too - give it a try.
Platform: MSW (Windows XP Pro)
Compiler: msvc 13.10.3077 (Free Toolkit)
wxWidgets: v2.6.0

daggmano
In need of some credit
In need of some credit
Posts: 6
Joined: Tue May 03, 2005 10:46 pm
Contact:

Post by daggmano » Tue May 03, 2005 11:34 pm

OK, that seems to have solved the problem when manually resizing, but not when normalising after being maximised. Thanks for the tip, anyway.

daggmano
In need of some credit
In need of some credit
Posts: 6
Joined: Tue May 03, 2005 10:46 pm
Contact:

Post by daggmano » Thu May 05, 2005 3:51 am

Actually, I just looked at it all again. GetVirtualSize() works the same as GetClientSize() (at least in this case), so I'm no closer to getting the solution to the problem. Strange that Linux and Windows seem to operate differently here.

Cursor
Earned some good credits
Earned some good credits
Posts: 120
Joined: Sun Aug 29, 2004 3:09 pm
Location: Grenoble, France
Contact:

Post by Cursor » Thu May 05, 2005 6:20 am

Perhaps beacause when you maximize, your frame client zone is greater than virtual one, so could you test with the max of them ?
What is little and green, witch go up and down ??
Yoda playing with the force.

Post Reply