Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to send events to extended child control?

How to send events to extended child control?

Scheduled Pinned Locked Moved C / C++ / MFC
questiontutorial
3 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rahul kulshreshtha
    wrote on last edited by
    #1

    I have extended a CComboBox and implemented three messages (or events) like below

     BEGIN\_MESSAGE\_MAP(CComboCtrl, CComboBox)
    ON\_WM\_KEYDOWN()
    ON\_CONTROL\_REFLECT(CBN\_EDITUPDATE, &CComboCtrl::OnCbnEditupdate)
    ON\_CONTROL\_REFLECT(CBN\_SELCHANGE, &CComboCtrl::OnCbnSelchange)
     END\_MESSAGE\_MAP()
    

    Now when a selection changes it calls OnCbnSelchange message-handler. I am using this class inside a dialog class. I have tried to register a message handler in that dialog class for CBN_SELCHANGE event but I think it is not receiving CBN_SELCHANGE event or it is sending that event to custom control. How can I handle CBN_SELCHANGE event inside a dialog class. This is the implementation inside derived class (or custom control class)

    void CComboCtrl::OnCbnSelchange()
    {
    // TODO: Add your control notification handler code here

    GetLBText(GetCurSel(),m\_str\_sel); //get previous text in combo. 
    

    }

    L 1 Reply Last reply
    0
    • R rahul kulshreshtha

      I have extended a CComboBox and implemented three messages (or events) like below

       BEGIN\_MESSAGE\_MAP(CComboCtrl, CComboBox)
      ON\_WM\_KEYDOWN()
      ON\_CONTROL\_REFLECT(CBN\_EDITUPDATE, &CComboCtrl::OnCbnEditupdate)
      ON\_CONTROL\_REFLECT(CBN\_SELCHANGE, &CComboCtrl::OnCbnSelchange)
       END\_MESSAGE\_MAP()
      

      Now when a selection changes it calls OnCbnSelchange message-handler. I am using this class inside a dialog class. I have tried to register a message handler in that dialog class for CBN_SELCHANGE event but I think it is not receiving CBN_SELCHANGE event or it is sending that event to custom control. How can I handle CBN_SELCHANGE event inside a dialog class. This is the implementation inside derived class (or custom control class)

      void CComboCtrl::OnCbnSelchange()
      {
      // TODO: Add your control notification handler code here

      GetLBText(GetCurSel(),m\_str\_sel); //get previous text in combo. 
      

      }

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      It's a long time since I used MFC message maps, but it looks to me like you are capturing the CBN_SELCHANGE notification in your control, so the dialog box won't see it. I think you may need to move that notification to the dialog or reflect it back somehow. Pual Di Lascia wrote an excellent paper[^] on MFC message processing which I recommend to anyone struggling with this subject.

      The best things in life are not things.

      R 1 Reply Last reply
      0
      • L Lost User

        It's a long time since I used MFC message maps, but it looks to me like you are capturing the CBN_SELCHANGE notification in your control, so the dialog box won't see it. I think you may need to move that notification to the dialog or reflect it back somehow. Pual Di Lascia wrote an excellent paper[^] on MFC message processing which I recommend to anyone struggling with this subject.

        The best things in life are not things.

        R Offline
        R Offline
        rahul kulshreshtha
        wrote on last edited by
        #3

        thanks Richard, you got the problem right. I am reading that article now.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups