Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » Bug in CExtNcFrameImpl::stat_MDI_Tile Collapse All
Subject Author Date
Offer Har Mar 14, 2009 - 8:18 AM

Continuing my report on the bug of tile horizontal appears as tile vertical:


http://www.prof-uis.com/prof-uis/tech-support/support-forum/weird-cextncwcmdiframewnd-behavior-63970.aspx#@lt;/p>

I think the bug is in this function. For example:



    if( nIndexY == 1 )
    {
        if( ! bHorizontal )
            nIndexY = nCount;
        else
            nIndexX = nCount;
    }

Should be the other way around - if we want tile horizontal, the Y count should be the number of child frames, not the X count.


Please check that you did not switch them all the way...

Technical Support Mar 15, 2009 - 8:39 AM

Thank you for reporting this issue. To fix it, please update the source code for the following method:

void CExtNcFrameImpl::stat_MDI_TileEWL( // explicit window list based version
            HWND hWndMdiClient,
            CList < HWND, HWND > & _list,
            bool bHorizontal
            )
{
            ASSERT( hWndMdiClient != NULL && ::IsWindow( hWndMdiClient ) );
INT nCount = INT( _list.GetCount() );
            if( nCount == 0 )
                        return;
    ShowScrollBar( hWndMdiClient, SB_BOTH, FALSE );
CRect rcClient;
    GetClientRect( hWndMdiClient, &rcClient );
CList < HWND, HWND > _listWindowsToSkip;
            rcClient.bottom -= stat_MDI_ArrangeIconic( hWndMdiClient, _listWindowsToSkip );
CSize sizeClient = rcClient.Size();
INT nRest = 1;
INT nIndexX = (INT)::sqrt( (double)nCount );
INT nIndexY = nIndexX;
    if( nIndexY == 1 )
            {
                        if( bHorizontal )
                                    nIndexY = nCount;
                        else
                                    nIndexX = nCount;
            }
            else
            {
                        for( ; true; )
                        {
                                    nRest = nCount - nIndexY * ( nIndexX - 1 );
                                    if( bHorizontal )
                                    {
                                                if( ( nRest - nIndexX ) >= nIndexY )
                                                            nIndexY ++;
                                                else
                                                            break;
                                    }
                                    else
                                    {
                                                if( ( nRest - nIndexY ) >= nIndexX )
                                                            nIndexX ++;
                                                else
                                                            break;
                                    }
                        }
    }
CSize sizeChild( sizeClient.cx / nIndexX, sizeClient.cy / nIndexY );
HDWP hDWP = ::BeginDeferWindowPos( nCount );
POSITION pos = _list.GetHeadPosition();
INT nWalkIndex = 0, nX, nY;
            for( nX = 0, nY = 0; nX < nCount; nX ++ )
            {
                        ASSERT( pos != NULL );
                        HWND hWnd = _list.GetNext( pos );
                        ASSERT( hWnd != NULL && ::IsWindow( hWnd ) );
                        CPoint ptTopLeft( 0, 0 );
                        if( bHorizontal )
                        {
                                    ptTopLeft.x = ( nWalkIndex - nY * nIndexX ) * sizeChild.cx;
                                    ptTopLeft.y = nY * sizeChild.cy;
                                    if(                     ( ( nWalkIndex % nIndexX ) == ( nIndexX - 1 ) )
                                                &&        ( nY < ( nIndexY - 1 ) )
                                                )
                                                nY ++;
                        }
                        else
                        {
                                    ptTopLeft.x = nY * sizeChild.cx;
                                    ptTopLeft.y = ( nWalkIndex - nY * nIndexY ) * sizeChild.cy;
                                    if(                     ( ( nWalkIndex % nIndexY ) == ( nIndexY - 1 ) )
                                                &&        ( nY < ( nIndexX - 1 ) )
                                                )
                                                nY ++;
                        }
                        hDWP =
                                    ::DeferWindowPos(
                                                hDWP, hWnd, NULL,
                                                ptTopLeft.x, ptTopLeft.y, sizeChild.cx, sizeChild.cy,
                                                SWP_NOACTIVATE|SWP_NOZORDER
                                                );
                        if( bHorizontal )
                        {
                                    if( nY == ( nIndexY - 1 ) )
                                                sizeChild.cx = sizeClient.cx / nRest;
                        }
                        else
                        {
                                    if( nY == ( nIndexX - 1 ) )
                                                sizeChild.cy = sizeClient.cy / nRest;
                        }
                        nWalkIndex ++;
            }
            ::EndDeferWindowPos( hDWP );
}