CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 1999
    Location
    UK (South)
    Posts
    93

    Bewildered by the ComboBox!!! Rescue me?



    Why does it not drop down a list.

    Im creating a new ToolBar with a ComboBox on it.

    In the resource editor I have added buttons to a new toolbar for the control and added the following code to the

    OnCreate() function in CMainFrame.

    *** m_wndToolBar2.Create(this,WS_CHILD|WS_VISIBLE|CBRS_TOP,IDR_FREQ_TOOL)

    *** m_wndToolBar2.LoadToolBar(IDR_FREQ_TOOL)

    Then to attach the Combo box.

    *** while(m_wndToolBar2.GetItemID(index)!=ID_FREQ_TOOL_COMBO)

    *** index++;

    *** m_wndToolBar2.SetButtonInfo(index,ID_FREQ_TOOL_COMBO,

    *** TBBS_SEPARATOR,250);

    *** m_wndToolBar2.GetItemRect(index,&rect);

    *** m_wndToolBar2.m_comboFreq.Create(WS_CHILD|

    *** WS_VISIBLE|WS_VSCROLL| WS_GROUP| CBS_DROPDOWNLIST,rect,

    *** (CWnd*) &m_wndToolBar2,ID_FREQ_TOOL_COMBO);

    This seems fine.

    In the CToolBar derived class I have added a member function to create the list in the Combo.

    *** BOOL CFreqTool::PopulateCombo(int noOfFreqs, float freqInc)

    *** {

    *** for (int freq=0; freq<noOfFreqs ; freq++)

    *** {

    *** CString text;

    *** text.Format("%.2f",freq*freqInc);

    *** m_comboFreq.AddString(text);

    *** }

    *** return TRUE;

    *** }

    And called this class from the document when the data to fill the list becomes available.

    *** CMainFrame* pFrame = (CMainFrame*) AfxGetApp()->m_pMainWnd;

    *** pFrame->m_wndToolBar2.PopulateCombo(m_maxFreqNum,m_freqIncrements);

    Running the Debbugger suggests that all is well at this point.

    However when I click on the control to view the list it does not drop down anything.

    The data is in the list because if you press any numbers you get the data appearing in the edit box.

    What do you think I could be missing?

    Simon Pettman

    Research Engnineer

    Goodmans Loudspeakers Ltd

    [email protected]

  2. #2
    Join Date
    May 1999
    Location
    UK (South)
    Posts
    93

    Even controls need their own space from time to time



    I found the solution. I needed to add more bottom to rect (if I cna say that).

    Otherwise the control did not have enough space to display its wares.


    Simon P

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured