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 General Discussion » How to use CExtBarUndoRedoButton? Collapse All
Subject Author Date
Viktor Korol Feb 17, 2006 - 11:27 AM

I wrote this code:

    //Add undo button to toolbar
    int nBtnIdx = m_wndToolBar.CommandToIndex(ID_EDIT_UNDO);
    VERIFY(m_wndToolBar.RemoveButton(nBtnIdx, FALSE));
    CExtBarUndoRedoButton *pUndo = new
        CExtBarUndoRedoButton(&m_wndToolBar, ID_EDIT_UNDO, 0);
    pUndo->SetSeparatedDropDown(true);
    VERIFY(m_wndToolBar.InsertSpecButton(nBtnIdx, pUndo, FALSE));

    //Add redo button to toolbar
    nBtnIdx = m_wndToolBar.CommandToIndex(ID_EDIT_REDO);
    VERIFY(m_wndToolBar.RemoveButton(nBtnIdx, FALSE));
    CExtBarUndoRedoButton *pRedo = new
        CExtBarUndoRedoButton(&m_wndToolBar, ID_EDIT_REDO, 0);
    pRedo->SetSeparatedDropDown(true);
    VERIFY(m_wndToolBar.InsertSpecButton(nBtnIdx, pRedo, FALSE));

How to add items to drop-down list. How receive messages, if user click on drop-down list item. Please advise with sample.

Technical Support Feb 18, 2006 - 8:27 AM

The popup menus with drop-down list box is easier to use in customizable applications like BitmapEditor where CMainFrame::OnPopupListBoxInitContent() overrides the CExtCustomizeSite::OnPopupListBoxInitContent() virtual method and initializes the undo/redo list box content for the ID_EDIT_UNDO and ID_EDIT_REDO commands. The CMainFrame::OnPopupListBoxSelEndOK() method in the BitmapEditor sample overrides the CExtCustomizeSite::OnPopupListBoxSelEndOK() virtual method and handles the final item selection event in the list box inside the popup menu dropped by the toolbar/menu item.

It is also possible to have undo/redo buttons in the non-customizable application. Create your own CExtBarUndoRedoButton-derived class which overrides at least the CExtBarUndoRedoButton::OnPopupListBoxInitContent() virtual method for initializing the list box with items and the CExtBarUndoRedoButton::OnPopupListBoxSelEndOK() virtual method for handling item selection. You can also customize the look of the list box items with overriding the CExtBarUndoRedoButton::OnPopupListBoxItemDraw() and CExtBarUndoRedoButton::OnPopupListBoxItemMeasure() virtual methods. You can override the CExtBarUndoRedoButton::OnPopupListBoxMeasureTrackSize() virtual method to change the size of the displayed list box menu.

Viktor Korol Feb 20, 2006 - 5:10 AM

In drop-down list in caption draws "Undo %d Actions". I need also "Redo %d Actions". How to easy customize this caption.

void CExtPopupUndoRedoMenuWnd::OnPaintUndoRedoCaption(
    CDC & dc,
    CRect rcItem
    )
{
    ASSERT_VALID( this );
    ASSERT_VALID( (&dc) );
    ASSERT( dc.GetSafeHdc() != NULL );
    
    CExtSafeString sCaption;
    sCaption.Format(
        _T("Undo %d Actions"),
        GetActionsCount()
        );

    g_PaintManager->PaintUndoRedoCaption(
        dc,
        rcItem,
        sCaption,
        this
        );
}

Technical Support Feb 21, 2006 - 5:46 AM

Unfortunately there is no easy way to customize the caption of the undo-redo popup menu in Prof-UIS 2.52. But we have just added this feature with regard to your feature request. Just wait for the next intermediate release or contact us via e-mail to get instructions how to download the update.

P.S. We added a new CExtCustomizeSite::OnPopupUndoRedoFormatCaption() virtual method which allows you to set any custom text for the caption. In the BitmapEditor sample we added the following code:

bool CMainFrame::OnPopupUndoRedoFormatCaption(
 CExtBarButton * pTBB,
 CExtCustomizeCmdTreeNode * pNode,
 CExtPopupUndoRedoMenuWnd * pUndoRedoPopupMenuWnd,
 CExtSafeString & strCaption
 )
{
#ifdef _DEBUG
 if( pTBB != NULL )
 {
  ASSERT_VALID( pTBB );
  ASSERT_VALID( pTBB->GetBar() );
 }
#endif // _DEBUG
 ASSERT_VALID( pNode );
 pTBB;
UINT nCmdID = pNode->GetCmdID(false);
 switch( nCmdID )
 {
 case ID_EDIT_UNDO:
  {
   strCaption.Format( 
    _T("Undo %d Actions"), 
    pUndoRedoPopupMenuWnd->GetActionsCount() 
    );
   return true;
  }
 case ID_EDIT_REDO:
  {
   strCaption.Format( 
    _T("Redo %d Actions"), 
    pUndoRedoPopupMenuWnd->GetActionsCount() 
    );
   return true;
  }
 } // switch( nCmdID )
 return false;
}