CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Jun 2001
    Location
    Wuerzburg, Germany
    Posts
    90

    Question How to put CComboBox and CButton in one?

    Hi,

    I need to get a CComboBox and a CButton by one ID. So I want to put them together in one class derived from CWnd.
    I did that with two buttons, no problem create the class with Create(_T("BUTTON"),...
    But now I need button and combo!

    How can I do that?

    Thanks

    Michael

  2. #2
    Join Date
    Apr 1999
    Posts
    3,585

    Re: How to put CComboBox and CButton in one?

    I need to get a CComboBox and a CButton by one ID.
    I'm not sure what you mean by the above. Are you trying to place them on a dialog? Can you explain your problem further?
    Gort...Klaatu, Barada Nikto!

  3. #3
    Join Date
    Jun 2001
    Location
    Wuerzburg, Germany
    Posts
    90

    Re: How to put CComboBox and CButton in one?

    Hi,

    I want to create a control as a combination of a CComboBox and a CButton (see attachment).
    I need it for a dynamic created view in wich I must know the ID of every control.
    Now I took CView as base-class. I can see the controls but no reaction.

    Michael
    Attached Images Attached Images  

  4. #4

    Re: How to put CComboBox and CButton in one?

    create a new class and derive it from CWnd.
    your class has two members CComboBox and CButton.
    in OnCreate event, create the two members on the position you need to.
    Code:
    int OnCreate( ... ) 
    {  
       ....
        // set some styles
        m_ctlCombo.Create( dwStyles, rcComboPos, (CWnd*) this, dwComboID );
        m_ctlButton.Create( _T("...")/*caption*/, dwStyles, rcButtonPos, (CWnd*) this, dwButtonID);
    }
    hope it helps

  5. #5
    Join Date
    Jun 2001
    Location
    Wuerzburg, Germany
    Posts
    90

    Re: How to put CComboBox and CButton in one?

    That is excactly what I did. The problem ist that I must call create on the class. And there I have to give the classname. If I do with "BUTTON" then the button works, if I do it with "COMBO" the combobox works. If I do it with NULL, none of them work.

    Michael

  6. #6
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: How to put CComboBox and CButton in one?

    Quote Originally Posted by MGS76
    That is excactly what I did. The problem ist that I must call create on the class. And there I have to give the classname. If I do with "BUTTON" then the button works, if I do it with "COMBO" the combobox works. If I do it with NULL, none of them work.

    Michael
    No, you may not use "BUTTON" nor "COMBO" for your custom window control. From MSDN :
    Its "class name can be any name registered with the global AfxRegisterWndClass function...."
    So call AfxRegisterWndClass to register the class name and use its return value as a
    class name The CWnd::Create needs.

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