CComboxEx selection change - Programmer

This is a discussion on CComboxEx selection change - Programmer ; I am trying to use a CComboboxEx within a CFormView. I have layed out my form with the resource editor and created a class for it. I added a CComboboxEx and I have populated it via InsertItem(). Now I want ...

+ Reply to Thread
Results 1 to 8 of 8

Thread: CComboxEx selection change

  1. CComboxEx selection change

    I am trying to use a CComboboxEx within a CFormView. I have layed out
    my form with the resource editor and created a class for it. I added a
    CComboboxEx and I have populated it via InsertItem(). Now I want to
    get notification when the selection in the combo box changes. I have
    tried handling several of the control's messages and I can't find any
    that are sent when the selection changes. I have included the relevent
    code below. Of all of the messages handled here, the only one I ever
    get is for CBEN_INSERTITEM.

    Can anyone point me in the right direction here? The CComboboxEx is a
    DropList type. I just need to get a notification when the selection
    changes.

    Thank you,
    Jen

    // CMyFormViewClass.h
    class CMyFormViewClass : public CFormView
    {
    DECLARE_DYNCREATE(CMyFormViewClass)

    protected:
    CMyFormViewClass(); // protected constructor used by dynamic creation
    virtual CMyFormViewClass();

    CComboBoxEx m_treatmentType;
    public:
    enum { IDD = IDD_FORMVIEW };
    protected:
    virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
    DECLARE_MESSAGE_MAP()
    virtual void OnInitialUpdate();
    public:
    afx_msg void OnInsertitemComboBox(NMHDR *pNMHDR, LRESULT *pResult);
    afx_msg void OnBegineditComboBox(NMHDR *pNMHDR, LRESULT *pResult);
    afx_msg void OnnEndEditChangeComboBox(NMHDR *pNMHDR, LRESULT
    *pResult);
    afx_msg void OnSelchangeComboBox();
    afx_msg void OnCloseupComboBox();
    };

    // CMyFormViewClass.cpp
    BEGIN_MESSAGE_MAP(CMyFormViewClass, CFormView)
    ON_NOTIFY(CBEN_INSERTITEM, IDC_COMBOBOXEX, OnInsertitemComboBox)
    ON_NOTIFY(CBEN_BEGINEDIT, IDC_COMBOBOXEX, OnBegineditComboBox)
    ON_NOTIFY(CBEN_ENDEDIT, IDC_COMBOBOXEX, OnEndEditChangeComboBox)
    ON_CBN_SELCHANGE(IDC_COMBOBOXEX, OnSelchangeComboBox)
    ON_CBN_CLOSEUP(IDC_COMBOBOXEX, OnCloseupComboBox)
    END_MESSAGE_MAP()

    //////
    // class funtions implemented appropriately
    //////


  2. Re: CComboxEx selection change

    As far as the selection change goes, you might want to catch the
    CBN_SELCHANGE notification message.

    AliR.

    "Jen" wrote in message
    news:1123012684.120265.291130@g47g2000cwa.googlegr oups.com...
    > I am trying to use a CComboboxEx within a CFormView. I have layed out
    > my form with the resource editor and created a class for it. I added a
    > CComboboxEx and I have populated it via InsertItem(). Now I want to
    > get notification when the selection in the combo box changes. I have
    > tried handling several of the control's messages and I can't find any
    > that are sent when the selection changes. I have included the relevent
    > code below. Of all of the messages handled here, the only one I ever
    > get is for CBEN_INSERTITEM.
    >
    > Can anyone point me in the right direction here? The CComboboxEx is a
    > DropList type. I just need to get a notification when the selection
    > changes.
    >
    > Thank you,
    > Jen
    >
    > // CMyFormViewClass.h
    > class CMyFormViewClass : public CFormView
    > {
    > DECLARE_DYNCREATE(CMyFormViewClass)
    >
    > protected:
    > CMyFormViewClass(); // protected constructor used by dynamic creation
    > virtual CMyFormViewClass();
    >
    > CComboBoxEx m_treatmentType;
    > public:
    > enum { IDD = IDD_FORMVIEW };
    > protected:
    > virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
    > DECLARE_MESSAGE_MAP()
    > virtual void OnInitialUpdate();
    > public:
    > afx_msg void OnInsertitemComboBox(NMHDR *pNMHDR, LRESULT *pResult);
    > afx_msg void OnBegineditComboBox(NMHDR *pNMHDR, LRESULT *pResult);
    > afx_msg void OnnEndEditChangeComboBox(NMHDR *pNMHDR, LRESULT
    > *pResult);
    > afx_msg void OnSelchangeComboBox();
    > afx_msg void OnCloseupComboBox();
    > };
    >
    > // CMyFormViewClass.cpp
    > BEGIN_MESSAGE_MAP(CMyFormViewClass, CFormView)
    > ON_NOTIFY(CBEN_INSERTITEM, IDC_COMBOBOXEX, OnInsertitemComboBox)
    > ON_NOTIFY(CBEN_BEGINEDIT, IDC_COMBOBOXEX, OnBegineditComboBox)
    > ON_NOTIFY(CBEN_ENDEDIT, IDC_COMBOBOXEX, OnEndEditChangeComboBox)
    > ON_CBN_SELCHANGE(IDC_COMBOBOXEX, OnSelchangeComboBox)
    > ON_CBN_CLOSEUP(IDC_COMBOBOXEX, OnCloseupComboBox)
    > END_MESSAGE_MAP()
    >
    > //////
    > // class funtions implemented appropriately
    > //////
    >
    >




  3. Re: CComboxEx selection change

    Thank you for your replies. Unfortunately, as you can see in the
    message map section I am handling the CBN_SELCHANGE notification. I
    have put a breakpoint in my handler for CBN_SELCHANGE and it is never
    being hit (this includes user selections).

    Any other suggestions for me?

    Thanks again,
    Jen


  4. Re: CComboxEx selection change

    Well I have made one interesting discovery. If I change the type of my
    CComboboxEx to Dropdown instead of Droplist I am getting the
    ON_SELCHANGE notifications. The problem is I really don't want the
    user to be able to type in the edit box - I want the droplist
    functionality.

    So how can I get notification of selection changes using a Droplist
    CComboboxEx?

    Thanks,
    Jen


  5. Re: CComboxEx selection change

    Why don't you cut&paste the RC code for your dialog? My guess is that
    you've got some property set wrong. I'm using a CCombobox in a dialog, with
    DropList and ON_CBN_SELCHANGE works just fine.

    --
    ---------------------------------------------------------------------
    DataGet & PocketLog www.dataget.com
    Data Collectors www.baxcode.com
    --------------------------------------------------------------------



    "Jen" wrote in message
    news:1123177638.421776.224880@g49g2000cwa.googlegr oups.com...
    > Well I have made one interesting discovery. If I change the type of my
    > CComboboxEx to Dropdown instead of Droplist I am getting the
    > ON_SELCHANGE notifications. The problem is I really don't want the
    > user to be able to type in the edit box - I want the droplist
    > functionality.
    >
    > So how can I get notification of selection changes using a Droplist
    > CComboboxEx?
    >
    > Thanks,
    > Jen
    >




  6. Re: CComboxEx selection change

    Certainly:

    IDD_MYDIALOG DIALOGEX 0, 0, 127, 50
    STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
    FONT 8, "MS Shell Dlg", 0, 0, 0x0
    BEGIN
    CONTROL "",IDC_COMBOBOXEX,"ComboBoxEx32",
    CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP,
    49,32,70,115
    END


  7. Re: CComboxEx selection change

    Can you use a regular CComboBox? Just for kicks, you might try it - if it
    doesn't work, then you'll know something else is wrong.

    From what I've got and know that works, and what MSDN says about
    CComboBoxEx, it looks like CComboBoxEx may NOT send a CBN_SELCHANGE. It
    looks like you might have to handle the WM_NOTIFY to get it.

    --
    ---------------------------------------------------------------------
    DataGet & PocketLog www.dataget.com
    Data Collectors www.baxcode.com
    --------------------------------------------------------------------



    "Jen" wrote in message
    news:1123268805.514438.220000@f14g2000cwb.googlegr oups.com...
    > Certainly:
    >
    > IDD_MYDIALOG DIALOGEX 0, 0, 127, 50
    > STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
    > FONT 8, "MS Shell Dlg", 0, 0, 0x0
    > BEGIN
    > CONTROL "",IDC_COMBOBOXEX,"ComboBoxEx32",
    > CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP,
    > 49,32,70,115
    > END
    >




  8. Re: CComboxEx selection change

    Well, thank you all for you help, I am embarrassed to say that the
    problem was with the resource id. There was a range of ids preceding
    the one selected for the combo box that was reserved for a custom
    control. It turns out I had an off by one error, and the id of the
    combo box should have been included in that reserved range.

    Jen


+ Reply to Thread