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 » ExtTabWnd, _SyncAllItems: changes to avoid Assertion failure...repost Collapse All
Subject Author Date
marc uchida Jun 4, 2009 - 11:11 AM

Hello,



I posted a problem in 2007 that was never replied to.  The issue has arisen again so I am re-posting.



see



http://www.prof-uis.com/prof-uis/tech-support/support-forum/exttabwnd-_syncallitems-changes-to-avoid-assertion-failure-57956.aspx .



The problem is related to a perceived logic error in ExtTabWnd’s _SyncAllItems().



Here is a clipping from that function with my notes inline...





       ModifyTabWndStyle(

            bCloseEnabled ? 0 : __ETWS_ENABLED_BTN_CLOSE,

            bCloseEnabled ? __ETWS_ENABLED_BTN_CLOSE : 0,

            false

            );

        INT nVisibleCount = 0;

        for( ; hWndMdiChild != NULL; hWndMdiChild = ::GetWindow( hWndMdiChild, GW_HWNDNEXT ) )

        {

// you code is checking for visibility property now

            if( ( ::GetWindowLong( hWndMdiChild, GWL_STYLE ) & WS_VISIBLE ) != 0 )

                nVisibleCount ++;





// your code now checks for handle

            LONG nIndexExist = ItemFindByHWND( hWndMdiChild, -1, true, true );

            if( nIndexExist >= 0 )

            {

// should the above visibility check be done here instead, after the handle is checked??

if( ( ::GetWindowLong( hWndMdiChild, GWL_STYLE ) & WS_VISIBLE ) != 0 )

         nVisibleCount ++;





                if( hWndMdiChild == pWndActiveMdiChild->GetSafeHwnd() )

                    SelectionSet( nIndexExist, true, false );

                continue;

            }

            ItemInsert(

                NULL,

                NULL, false,

                0,

                -1,

                LPARAM( hWndMdiChild ),

                false

                );



In general, it seems like the code would be better served if the property is checked after a valid handle is confirmed.



Can this be changed for your next version?  This will save us from having to continue employing an override of the _SyncAlItems() function and checking it each time you do a new release.



thanks for you time,



marc, vorum research

Technical Support Jun 5, 2009 - 3:57 AM

We probably lost your forum message because of site maintenance. We are sorry.

Here is the loop with code statement inside:

               for( ; hWndMdiChild != NULL; hWndMdiChild = ::GetWindow( hWndMdiChild, GW_HWNDNEXT ) )
                        {
                                    if( ( ::__EXT_MFC_GetWindowLong( hWndMdiChild, GWL_STYLE ) & WS_VISIBLE ) != 0 )
                                                nVisibleCount ++;
                                    LONG nIndexExist = ItemFindByHWND( hWndMdiChild, -1, true, true );
                                    if( nIndexExist >= 0 )
                                    {
                                                if( hWndMdiChild == pWndActiveMdiChild->GetSafeHwnd() )
                                                            SelectionSet( nIndexExist, true, false );
                                                continue;
                                    }
                                    ItemInsert(
                                                NULL,
                                                NULL, false,
                                                0,
                                                -1,
                                                LPARAM( hWndMdiChild ),
                                                false
                                                );
                                    if( hWndMdiChild == pWndActiveMdiChild->GetSafeHwnd() )
                                                SelectionSet( ItemGetCount()-1, true, false );
                        } // for( ; hWndMdiChild != NULL; hWndMdiChild = ::GetWindow( hWndMdiChild, GW_HWNDNEXT ) )
Only the valid MDI child frame window handles are reviewed by this loop’s statement. If the tab item does not exist for the currently enumerated window handle, then the tab item is added, otherwise not. It’s not important where to count visible MDI child frames if the window handles are always valid.