Thread: How to add a combobox in the statusbar?

  1. #1
    Registered User
    Join Date
    Aug 2003
    Posts
    7

    How to add a combobox in the statusbar?

    hi all,
    I don't know how to add a combobox in the statusbar can anyone help me.

    amrsfmt

  2. #2
    Programming is fun, mkay?
    Join Date
    Oct 2001
    Posts
    490

    Question What API?

    Are you using the Win32 API or MFC?

  3. #3
    Registered User
    Join Date
    Aug 2003
    Posts
    7
    hi all,

    I would be glad if I know how to do it in both ways,
    but know I need the MFC way.
    I'm working with MFC.

    amrsfmt

  4. #4
    Programming is fun, mkay?
    Join Date
    Oct 2001
    Posts
    490

    Post Try this solution ...

    Well, in both MFC and the Win32 API, you would just create it as a child of the status bar. Anyhow, here is how you would do it. First, add a member to the CMainFrame class (CMainFrm.h by default) like this:

    CComboBox m_wndCombo; // Our combobox control

    In your CMainFrm.cpp file, you would do this (in the OnCreate function):

    Code:
    m_wndCombo.Create(WS_CHILD | WS_VISIBLE,   // Styles
                                        CRect(0, 0, 200, 20),    // Size and position
                                        m_wndStatusBar,    // Parent window
                                        1001);
    That should do what you need. You can change the parameters of "CRect()" to adjust position and size. If you need anymore help, just post a reply.

  5. #5
    Registered User
    Join Date
    Aug 2003
    Posts
    7

    Thanks,

    thanks for your reply,
    but I have this error:

    error C2664: 'Create' : cannot convert parameter 3 from 'class CStatusBar' to 'class CWnd *'
    I know there is a method to get the CWnd pointer but I don't remember it, I have searched the MSDN and didn't find it.

    amrsfmt

  6. #6
    Registered User
    Join Date
    Aug 2003
    Posts
    7
    hi all,

    thanks SyntaxBubble for your reply,
    I have fixed the problem.
    Code:
    m_wndCombo.Create(WS_CHILD | WS_VISIBLE | WS_VSCORLL | CBS_DROPDOWNLIST,   // Styles
                                        CRect(0, 0, 200, 20),    // Size and position
                                        &m_wndStatusBar,    // Parent window
                                        1001);
    that's was the problem,
    know there is another problem that when I drop down the the list. It's limited by the size of the status bar which limit the viewing of the dropdown list, I think this problem my be solved by sizing the statusbar bigger.
    Is that right?

    thanks bye,
    amrsfmt

  7. #7
    Programming is fun, mkay?
    Join Date
    Oct 2001
    Posts
    490

    Question Have you tried this?

    Have you just tried changing the fourth (last) parameter in the CRect() function? If not, try to see if that is the problem. BTW, I'm glad I was of help to you.

  8. #8
    Registered User
    Join Date
    Feb 2003
    Posts
    9
    Try setting the height of the combo box to something like 100 and see if that works for you.

    Good luck,
    Chris

  9. #9
    Registered User
    Join Date
    Aug 2003
    Posts
    7
    thanks for your help,
    that's what I have done exactly,
    I have made the hight of the combobox 100,
    so it worked.

    thanks,
    amrsfmt

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. textBox, comboBox
    By Coding in forum C# Programming
    Replies: 4
    Last Post: 02-16-2008, 09:53 PM
  2. combobox reacts strangely to a mouse
    By johny145 in forum Windows Programming
    Replies: 2
    Last Post: 03-07-2005, 05:32 PM
  3. Win32 COMBOBOX 'Enter' Key??
    By tdk_ratboy in forum Windows Programming
    Replies: 0
    Last Post: 04-17-2004, 05:52 PM
  4. Can somebody test this code please
    By andy bee in forum C Programming
    Replies: 6
    Last Post: 10-09-2001, 03:08 PM
  5. Add String To Combobox?
    By (TNT) in forum Windows Programming
    Replies: 1
    Last Post: 09-15-2001, 04:40 AM