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 » Toolbar not resizing for a CExtComboBox control Collapse All
Subject Author Date
Kishore Gagrani Sep 25, 2003 - 2:00 PM

I’m trying to put a CExtComboBox control on a toolbar, using the code from the ProfStudio example. The toolbar is not expanding to fit the control though - instead the combobox extends over any following buttons, and is truncated at the end of the toolbar. I can’t for the life of me figure out what’s different between what I’m doing and what is being done in the ProfStudio example. This is the code I’m using:

   CString strTitle;
   strTitle.LoadString(IDS_VIEWTOOLBAR);

   if ( !m_wndViewToolBar.Create(strTitle, this, ID_VIEW_VIEWTOOLBAR) || 
        !m_wndViewToolBar.LoadToolBar(IDR_VIEWTOOLBAR))
   {
      TRACE0("Failed to create View Toolbar\n");
      return(FALSE);      // fail to create
   }
   if (m_comboView.Create( WS_CHILD | CBS_HASSTRINGS | CBS_DROPDOWNLIST | WS_VISIBLE,
                           CRect(0,0,200,300),
                           &m_wndViewToolBar,
                           ID_VIEW_BS_TYPECOMBO))
   {
      VERIFY( m_wndViewToolBar.SetButtonCtrl( m_wndViewToolBar.CommandToIndex( ID_VIEW_BS_TYPECOMBO ),
                                              &m_comboView ));

      m_comboView.SetFont( CFont::FromHandle( (HFONT)::GetStockObject(DEFAULT_GUI_FONT) ));
      m_comboView.SetItemHeight( -1, m_comboView.GetItemHeight( -1 ) - 1);

      m_comboView.AddString( _T("Win32 Debug") );
      m_comboView.AddString( _T("Win32 Release") );
      m_comboView.AddString( _T("Win32 Unicode Debug") );
      m_comboView.AddString( _T("Win32 Unicode Release") );
      m_comboView.SetCurSel( 0 );

   }

   m_wndViewToolBar.EnableDocking(CBRS_ALIGN_ANY);

Any ideas as to what’s wrong? Maybe I’m not initializing a property somewhere? I traced into CExtBarButton::CalculateLayout() and it is recognizing that it’s a control and calculating the active size correctly.

Technical Support Sep 26, 2003 - 12:03 AM

Dear Kishore,

We suppose the problem in question hides somewhere in CMainFrame::OnCreate(). Please let us take a look at the complete code of the method or send us your project.

Kishore Gagrani Oct 6, 2003 - 6:35 AM

Thanks for the quick response. Sorry I didn’t get back to you sooner, but I was pulled off to fight a fire somewhere else.

I did poke around a little, and found that the problem is caused by enabling the customization option. I was able to duplicate it in the ProfStudio example, by doing the following.

1) Added

#include "ExtCustomize.h"
to MainFrm.h at line 42 2) Added
class CExtCustomizeSite;
to MainFrm.h at line 52;

3) I changed line 97 of MainFrm.h by adding
 , public CExtCustomizeSite
to the end of the class declaration. 4) Added the following code to MainFrm.cpp, at line 2164:
	VERIFY( CExtCustomizeSite::MenuInfoAdd( this, 
                                           _T("Default"), 
                                           IDR_MAINFRAME, 
                                           true,
                                           false,
                                           RUNTIME_CLASS( CMainFrame )));
	if( !CExtCustomizeSite::EnableCustomization( this ) )
	{
		ASSERT( FALSE );
		return -1;
	}
	CExtCustomizeSite::CategoryUpdate( IDR_MAINFRAME );

This caused the toolbars to stop sizing to fit the comboboxes. Any ideas on how I can get around the problem?

Technical Support Oct 9, 2003 - 1:46 AM

Hi,

Sorry for the delay with this answer.

Customizable toolbars should not have combo-box windows inside. The CExtComboBox window cannot be resized in the Customize Mode. It cannot be dropped onto menu either.

For that, please use build-in combo-field items. The StyleEditor sample demonstrates their usage. Please note that such combo items feature automatic content synchronization between different copies of one combo-command. Send send us your CMainFrame’s class source code (.H and .CPP) files so that we can help you fix the problem.

Kishore Gagrani Oct 15, 2003 - 5:59 AM

That did it! I switched to the combo-field item and it worked like a charm. Thanks for the help!