[wxPython] Strange Error

This type of error comes from the C++ code for wxWindows. To see the C++
source files you need to download wxWindows. The method in question is
below. This problem came up for me when I upgraded to wxPython 2.3.2.1.
IIRC I got around it by moving the position/size for my wxFrame window
from the constructor to Move/SetSize method calls just after the
constructor. I don't know if it has any relationship, but I am doing a
lot of funny stuff in my override of wxFrame.SetSize.

Jimmy

void wxWindowMSW::DoSetClientSize(int width, int height)
{
    // setting the client size is less obvious than it it could have
been
    // because in the result of changing the total size the window
scrollbar
    // may [dis]appear and/or its menubar may [un]wrap and so the client
size
    // will not be correct as the difference between the total and
client size
    // changes - so we keep changing it until we get it right
    //
    // normally this loop shouldn't take more than 2 iterations (usually
1 but
    // if scrollbars [dis]appear as the result of the first call, then
2) but
    // just to be on the safe side we check for it instead of making it
an
    // "infinite" loop (i.e. leaving break inside as the only way to get
out)
    for ( int i = 0; i < 3; i++ )
    {
        RECT rectClient;
        ::GetClientRect(GetHwnd(), &rectClient);

        // if the size is already ok, stop here (rectClient.left = top =
0)
        if ( rectClient.right == width && rectClient.bottom == height )
        {
            break;
        }

        if ( i == 2 )
        {
            // how did it happen? maybe OnSize() handler does something
really
            // strange in this class?
            wxFAIL_MSG( _T("logic error in DoSetClientSize") );

            break;
        }

        int widthClient = width,
            heightClient = height;

        // Find the difference between the entire window (title bar and
all)
        // and the client area; add this to the new client size to move
the
        // window
        RECT rectWin;
        ::GetWindowRect(GetHwnd(), &rectWin);

        widthClient += rectWin.right - rectWin.left - rectClient.right;
        heightClient += rectWin.bottom - rectWin.top -
rectClient.bottom;

        POINT point;
        point.x = rectWin.left;
        point.y = rectWin.top;

        // MoveWindow positions the child windows relative to the
parent, so
        // adjust if necessary
        if ( !IsTopLevel() )
        {
            wxWindow *parent = GetParent();
            if ( parent )
            {
                ::ScreenToClient(GetHwndOf(parent), &point);
            }
        }

        DoMoveWindow(point.x, point.y, widthClient, heightClient);
    }
}

···

-----Original Message-----
From: Chris Rouse [mailto:crouse@lanset.com]
Posted At: Sunday, February 10, 2002 1:13 AM
Posted To: wxPython
Conversation: [wxPython] Strange Error
Subject: [wxPython] Strange Error

c:\Projects\wx\src\msw\window.cpp (1521): assert failed: logic error in
DoSetClientSize.

I really have no idea what is doing this. I can't find the function to
see
what is going wrong. any idea...

Chris Rouse

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwindows.org
http://lists.wxwindows.org/mailman/listinfo/wxpython-users