Toolbar:Dynamically adding a combo box 
Author Message
 Toolbar:Dynamically adding a combo box

I am trying to add a combo box to my tool bar on the fly as well as delete
the CB.  I have been trying to use the model in the ctrlbars example, where
they add and delete buttons to a tool bar on the fly.  This sort of works,
but I am trying to add a combo box.  This does not work very well.

When the bar is first displayed, it does not extend its size, and the CB and
the buttons added to the bar are not displyed correctly or not at all.  The
CB is display the size of the two buttons it replaces (because I am
inserting the CB in the toolbar).  Once I click the toolbar, it magically
expands and all is displayed correctly and it works great from there.

But this sort of action is not acceptable.

Can someone please help, I have been wasting hours trying to overcome this
problem.

Thanks,

Chris Love



Sun, 18 Feb 2001 03:00:00 GMT  
 Toolbar:Dynamically adding a combo box

Quote:

>I am trying to add a combo box to my tool bar on the fly as well as delete
>the CB.  I have been trying to use the model in the ctrlbars example, where
>they add and delete buttons to a tool bar on the fly.  This sort of works,
>but I am trying to add a combo box.  This does not work very well.

>When the bar is first displayed, it does not extend its size, and the CB
and
>the buttons added to the bar are not displyed correctly or not at all.  The
>CB is display the size of the two buttons it replaces (because I am
>inserting the CB in the toolbar).  Once I click the toolbar, it magically
>expands and all is displayed correctly and it works great from there.

>But this sort of action is not acceptable.

>Can someone please help, I have been wasting hours trying to overcome this
>problem.

I'm not sure about your specific situation, but I plug controls into
toolbars like this:

- have a ID_SEPARATOR in the toolbar resource where I want the control to go

- then

 //create the bar and set it's styles
 if
(!m_wndSomeBar.Create(this,WS_CHILD|WS_VISIBLE|CBRS_BOTTOM,AFX_IDW_TOOLBAR+1
1) ||
  !m_wndSomeBar.LoadToolBar(IDR_SOMEBAR))
 {
  return -1;
 }
 m_wndSomeBar.SetBarStyle(m_wndSomeBar.GetBarStyle() |
  CBRS_TOOLTIPS | CBRS_SIZE_DYNAMIC );

    //resize the separator (at position 5 in this case) to the size you want
the control in, in advance (!)
    m_wndSomeBar.SetButtonInfo(5,ID_SEPARATOR,TBBS_SEPARATOR,48);

    //now get the space that is actually available after this
    CRect iRect;
    m_wndSomeBar.GetItemRect(5,&iRect);
    //and create the control to fit this space

m_wndSomeEditCtrl.Create(NULL,WS_CHILD|WS_VISIBLE|SS_CENTER,iRect,&m_wndSome
Bar,IDC_SOMEEDIT);
    //Set Styles and font to something reasonable. Could use CreateEx
instead also
    m_wndSomeEditCtrl.ModifyStyleEx(0,WS_EX_CLIENTEDGE);
 m_wndSomeEditCtrl.SetFont(m_wndSomeBar.GetFont());

    //do the usual EnableDocking things

cU
--

   http://djuga.home.ml.org
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Retriever 2.0 is out: http://retriever.home.ml.org

Shareware image viewer, thumbnailer & database
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



Sun, 18 Feb 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. How to add a combo box to toolbar?

2. Add combo box on toolbar

3. Add Combo Box to Dialog Box

4. Add a combo box in a dialog box...

5. Changing syle of a combo box dynamically

6. how to place font or color combo box in toolbar

7. Toolbar with Combo Box

8. combo box and toolbar

9. q: toolbar drop down combo box and document data

10. Adding a toolbar dynamically to a rebar

11. MFC/SDI: "Combo Box" and Toolbar

12. How to insert a combo box into a toolbar

 

 
Powered by phpBB® Forum Software