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 » CExtTab question Collapse All
Subject Author Date
tera tera Jun 8, 2009 - 12:17 AM

Hello.


When only one tab is displayed , I want to non-display a tab domain.

Is this impossible?


Technical Support Jun 8, 2009 - 10:59 AM

It’s possible to make the CExtTabWnd window and any other CExtTabWnd-derived tabs invisible when there is only one tab item displayed. You should override the CExtTabWnd::OnTabWndSyncVisibility() virtual method and hide the tab window when it have only one tab item or zero tab items. All the MDI tab controls in Prof-UIS use the following overridden version of the CExtTabWnd::OnTabWndSyncVisibility() virtual method for hiding tab window when the tab item count is zero:

   virtual void OnTabWndSyncVisibility()
            {
                        LONG nItemCount = ItemGetCount();
                        LONG nItemVisibleCount = ItemGetVisibleCount();
                        DWORD dwWndStyle = GetStyle();
                        if(                     nItemCount > 0 
                                    &&        nItemVisibleCount > 0
                                    &&        (!(                     CExtControlBar::FindPrintPreviewMode(
                                                                                    STATIC_DOWNCAST( CFrameWnd, GetParent() )
                                                                                    )
                                                            ||           CExtControlBar::IsOleIpObjActive(
                                                                                    STATIC_DOWNCAST( CFrameWnd, GetParent() )
                                                                                    )
                                                ) )
                                    )
                        {
                                    if( (dwWndStyle & WS_VISIBLE) == 0 )
                                    {
                                                ::SetWindowPos(
                                                            m_hWnd,
                                                            NULL, 0, 0, 0, 0,
                                                            SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOOWNERZORDER
                                                                        |SWP_FRAMECHANGED
                                                                        |SWP_SHOWWINDOW
                                                            );
                                                HWND hWndMdiArea = _GetHwndMdiArea();
                                                if( hWndMdiArea != NULL )
                                                            ::SetWindowPos(
                                                                        hWndMdiArea,
                                                                        NULL, 0, 0, 0, 0,
                                                                        SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOOWNERZORDER
                                                                                    |SWP_FRAMECHANGED
                                                                        );
                                    }
                        } // if( nItemCount > 0 ...
                        else
                        {
                                    if( (dwWndStyle & WS_VISIBLE) != 0 )
                                                ::SetWindowPos(
                                                            m_hWnd,
                                                            NULL, 0, 0, 0, 0,
                                                            SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOOWNERZORDER
                                                                        |SWP_NOSENDCHANGING
                                                                        |SWP_HIDEWINDOW
                                                            );
                        } // else from if( nItemCount > 0 ...
                        dwWndStyle = GetStyle();
                        if( (dwWndStyle & WS_VISIBLE) == 0 )
                                    m_nIndexVisFirst = m_nIndexVisLast = -1;
            }
You can use this source code in your tabs class and hide the tab window if the number of tabs is less or equal to 1.

The Prof-UIS tab page containers have the same method even with the same name for synchronizing visibility of inner tab window:
void CExtTabPageContainerWnd::OnTabWndSyncVisibility()
{
            ASSERT_VALID( this );
            if( GetSafeTabWindow() == NULL )
                        return;
LONG nItemCount = m_pWndTab->ItemGetCount();
LONG nItemVisibleCount = m_pWndTab->ItemGetVisibleCount();
DWORD dwWndStyle = m_pWndTab->GetStyle();
            if(                     nItemCount > 0 
                        &&        nItemVisibleCount > 0
                        &&        m_bTabWndVisible
                        )
            {
                        if( (dwWndStyle & WS_VISIBLE) == 0 )
                                    m_pWndTab->SetWindowPos(
                                                NULL, 0, 0, 0, 0,
                                                SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOOWNERZORDER|SWP_FRAMECHANGED|SWP_SHOWWINDOW
                                                );
            }
            else
            {
                        if( (dwWndStyle & WS_VISIBLE) != 0 )
                                    m_pWndTab->SetWindowPos(
                                                NULL, 0, 0, 0, 0,
                                                SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOOWNERZORDER|SWP_HIDEWINDOW
                                                );
            }
}
This method also does not hide tabs with only one tab item visible. So, if you are using tab page container control, then you can override the CExtTabPageContainerWnd::OnTabWndSyncVisibility() virtual method and hide tabs with one visible tab item.