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 » Floating bar with a grid problem Collapse All
Subject Author Date
Offer Har Sep 18, 2008 - 5:46 PM

I have a floating bar. Inside the bar I have CExtTreeGridWnd with two columns. The columns width are set with ExtentPercentSet.


In some place in the flow I need to resize the bar. I do it using a call to SetInitDesiredSizeFloating. The problem is that the grid does not get the call, and the columns percent is not updated until I resize the bar with the mouse.


Is there a better way to progrematicaly resize an existing bar?


Is there a way to force the grid to update the columns sizes?

Technical Support Sep 22, 2008 - 12:04 PM

Are you using the following code at the end of tree grid initialization?

    wndTreeGrid.OnSwUpdateScrollBars();
    wndTreeGrid.OnSwRecalcLayout( true );
Are you using the CExtControlBar class "as is" or you have derived your own control bar class which may eat size changing notifications somehow? If would be also very interesting to take a look at the complete tree grid initialization code.

Offer Har Sep 22, 2008 - 1:16 PM

I use a derived class, but it does not eat events at all. it doesn’t even have any message map macros.


I have these two lines, but still, the grid does not adjust the columns unless I manualy resize the bar.


This is what I do when I need to show the bar:



        POINT pt;
        GetCursorPos(&pt);
        SetInitDesiredSizeFloating(CSize(200, 300));
        SetInitDesiredPosFloating(pt);
        FloatControlBar(pt);
        CFrameWnd* pFrame = GetParentFrame();
        pFrame->RecalcLayout();
        pFrame->SendMessage(WM_NCPAINT); 
        ((CFrameWnd*)AfxGetMainWnd())->ShowControlBar(this, TRUE, FALSE);
        m_pPropTree->OnSwUpdateScrollBars();
        m_pPropTree->OnSwDoRedraw();
        m_pPropTree->OnSwRecalcLayout( true );

And still, it does not resize/update the columns widths in the tree grid.

Technical Support Sep 23, 2008 - 5:49 AM

This source code is absolutely OK. It would be much more interesting to take a look at the tree grid’s initialization source code where all the styles are applied and columns inserted.

Offer Har Sep 23, 2008 - 6:29 AM

Called at initialization time:



bool CMyTreeGrid::Init()
{
    SiwModifyStyle(
        (__ESIS_STH_NONE|__ESIS_STV_ITEM)        // Item scroll window styles
        | __EGBS_SFB_FULL_ROWS                    // Selection/focus type - full rows
        | __EGBS_DYNAMIC_RESIZING                // Resize rows/columns on-the-fly
        | __EGBS_RESIZING_CELLS_OUTER            // enable row/column resizing
        ,0, false);

    SiwModifyStyleEx(
        __EGBS_EX_CELL_TOOLTIPS_INNER
        | __EGBS_EX_CELL_EXPANDING_INNER
        | __EGWS_EX_PM_COLORS
        | __EGBS_EX_CORNER_AREAS_3D
        | __EGBS_EX_CORNER_AREAS_CURVE
        | __EGBS_EX_HVI_EVENT_CELLS
        ,0, false);

    BseModifyStyleEx(__EGBS_BSE_EX_PROPORTIONAL_COLUMN_WIDTHS);

    OuterRowCountTopSet(1, false);
    OuterRowHeightSet(true, 0, 0);
    ColumnAdd(2, false);
 
    CExtGridCellHeader* pCellHdr = (CExtGridCellHeader*)GridCellGetOuterAtTop(0, 0, RUNTIME_CLASS(CExtGridCellHeader));
    pCellHdr->ExtentPercentSet(0.4);

    pCellHdr = (CExtGridCellHeader*)GridCellGetOuterAtTop(1, 0, RUNTIME_CLASS(CExtGridCellHeader));
    pCellHdr->ExtentPercentSet(0.6);

    g_PaintManager->LoadWinXpTreeBox(m_iconTreeBoxExpanded, true);
    g_PaintManager->LoadWinXpTreeBox(m_iconTreeBoxCollapsed, false);

    return true;
}

Technical Support Sep 24, 2008 - 5:00 AM

The three grid initialization code is absolutely OK. We created a small test project with a tree grid inside a control bar and your tree grid initialization code "as is". We failed to reproduce the problem with it.

TestTreeGridInFloatingBar.zip

Please help us to reproduce the problem.

Offer Har Sep 25, 2008 - 6:04 AM

Dear Support,


Thank you for the application - I was able to reproduce the bug easily with your application.


Add this command handler to the CMainFrm, and a matching command to the main frame menu:



void CMainFrame::OnCommandReopen()
{

    POINT pt;
    GetCursorPos(&pt);
    m_wndResizableBar.SetInitDesiredSizeFloating(CSize(200, 300));
    m_wndResizableBar.SetInitDesiredPosFloating(pt);
    m_wndResizableBar.FloatControlBar(pt);
    CFrameWnd* pFrame = m_wndResizableBar.GetParentFrame();
    pFrame->RecalcLayout();
    pFrame->SendMessage(WM_NCPAINT); 

    ShowControlBar(&m_wndResizableBar, TRUE, FALSE);

    m_wndTreeGrid.OnSwDoRedraw();
    m_wndTreeGrid.OnSwRecalcLayout( true );
}

Now, run the application, close the bar, and press the command - the bar will re-appear.


You will see that when the bar re-appear the columns of the tree in it are not divided 40-60 until you resize the bar - that’s the bug.


Thanks,


Ron.


 

Technical Support Sep 26, 2008 - 12:27 PM

We have done just as you explained. But everything seems OK. Here is the updated source code and compiled binaries:

http://www.prof-uis.com/download/forums/TestTreeGridInFloatingBar2.zip

Offer Har Sep 26, 2008 - 12:32 PM

Dear Support,


I just ran your executable and the bug is there...


To see it more clearly do this - before closing the bar make it very wide, so that when you re-open the column separator will not be shown at all, then resize the bar you’ll see the columns separator popping.


Ron.


 

Offer Har Sep 27, 2008 - 4:53 PM

Were you able to see the bug now?

Offer Har Sep 22, 2008 - 7:45 AM

The parent is CExtControlBar. I create the tree grid, and it’s parent is the CExtControlBar like this in a CExtControlBar derived class:

m_pPropTree = new CExtNSB<CMyTreeGrid>;
m_pPropTree->Create(this);



I resize the CExtControlBar using the methods mentioned above, which resizes the control bar,  and I guess does not call the child WM_SIZE.

Technical Support Sep 19, 2008 - 11:41 AM

It is not enough to invoke the CExtControlBar::SetInitDesiredSizeFloating() method. You should re-compute the layout of control bar’s parent frame window which is a floating mini frame window if the control bar is in the floating state. The CChangeFloatingSizeView::OnButtonFloat() method in the following test project does this:

http://www.prof-uis.com/download/forums/ChangeFloatingSize2.zip

Here is the method’s source code:

void CChangeFloatingSizeView::OnButtonFloat() 
{
      UpdateData( TRUE );
CExtControlBar & bar = ( STATIC_DOWNCAST( CMainFrame, GetParentFrame() ) ) -> m_wndResizableBar;
CPoint pt( m_nEditLeft, m_nEditTop );
CSize sz( m_nEditWidth, m_nEditHeight );
      bar.SetInitDesiredPosFloating( pt );
      bar.SetInitDesiredSizeFloating( sz );
      bar.FloatControlBar( pt );
CFrameWnd * pFrame = bar.GetParentFrame();
      ASSERT_VALID( pFrame );
      if( pFrame->IsKindOf( RUNTIME_CLASS( CMiniDockFrameWnd ) ) )
      {
            pFrame->RecalcLayout();
            pFrame->SendMessage( WM_NCPAINT ); 
      }
}

Offer Har Sep 19, 2008 - 5:39 PM

This is exactly what I’m doing already. It does not work.


The grid control inside the bar does not get resized when this code is reached. Maybe there is a bug in eth bars?

Technical Support Sep 22, 2008 - 7:40 AM

What is the parent window of your grid window? Is it a control bar or if there is some window between the grid and the control bar? We know that the grid window re-computes the layout of its parts correctly when it receives a WM_SIZE message. If the layout is not updated then the grid window was not resized or it didn’t receive the WM_SIZE message due to any reason like the parent class method was not envoked etc.

Offer Har Sep 22, 2008 - 7:45 AM

The parent is CExtControlBar. I create the tree grid, and it’s parent is the CExtControlBar like this in a CExtControlBar derived class:


m_pPropTree = new CExtNSB<CMyTreeGrid>;
m_pPropTree->Create(this);



I resize the CExtControlBar using the methods mentioned above, which resizes the control bar,  and I guess does not call the child WM_SIZE.