• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1403
  • Last Modified:

Control Reflection

Hi

I have a ComboBox derived class. I want to handle the CBN_SELCHANGE notification
in the combobox.

I am using

ON_CONTROL_REFLECT(CBN_SELCHANGE, OnSelchange)

in my message map in ComboBox class. I cannot get it to catch
the message.

I Create the combobox as follows in a CMsFlexGrid derived class as follows

m_pPCombo = new CPropertyComboBox();
if (!m_pPCombo->Create(WS_CHILD|WS_VSCROLL|CBS_DROPDOWNLIST, CRect(0,0,100,100), this, IDC_PROP_COMBO)) {

}


What am i doing wrong??

Thanks in advance
anti

 
0
antinutrino
Asked:
antinutrino
  • 3
  • 3
  • 2
  • +1
1 Solution
 
nonubikCommented:
Try

ON_CONTROL_REFLECT(CBN_SELCHANGE, OnSelchange)
0
 
nonubikCommented:
Hmm, I though you posted the question with CDB_SELCHANGE instead of CBN_SELCHANGE. Did you recently modified the question?
0
 
nonubikCommented:
For me it worked just fine.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
AxterCommented:
Hi antinutrino,
> >in my message map in ComboBox class. I cannot get it to catch
> >the message.
Can you post the entire message map block.
It should have CComboBox or derived class of CComboBox in the BEGIN_MESSAGE_MAP section.
Example:
BEGIN_MESSAGE_MAP(CComboBoxBrowseCtrl, CComboBox)
    //{{AFX_MSG_MAP(CComboBoxBrowseCtrl)
    ON_CONTROL_REFLECT(CBN_SELCHANGE, OnSelchange)
    //}}AFX_MSG_MAP
END_MESSAGE_MAP()

In your header, you should have OnSelchange within the AFX_MSG block.
Example:
    //{{AFX_MSG(CComboBoxBrowseCtrl)
    afx_msg void OnSelchange();
    //}}AFX_MSG

Please post more of your code, so we can get the complete picture.

David Maisonave :-)
Cheers!
0
 
AxterCommented:
antinutrino,
You also need DECLARE_MESSAGE_MAP() in your CComboBox derived class header.
    // ClassWizard generated virtual function overrides
    //{{AFX_VIRTUAL(CComboBoxBrowseCtrl)
    protected:
    //}}AFX_VIRTUAL
// Implementation
protected:
    //{{AFX_MSG(CComboBoxBrowseCtrl)
    afx_msg void OnSelchange();
    //}}AFX_MSG

    DECLARE_MESSAGE_MAP()

Check out following links for example:
http://code.axter.com/BrowseCtrl.h
http://code.axter.com/BrowseCtrl.cpp


David Maisonave :-}
0
 
antinutrinoAuthor Commented:
Hi

Header:

....

// Overrides
      // ClassWizard generated virtual function overrides
      //{{AFX_VIRTUAL(CPropertyComboBox)
      //}}AFX_VIRTUAL

// Implementation
public:
      CPropertyTabCtrl* m_pTab;
      virtual ~CPropertyComboBox();

      // Generated message map functions
protected:
      //{{AFX_MSG(CPropertyComboBox)
      afx_msg void OnKillFocus(CWnd* pNewWnd);
      afx_msg void OnSelChange();
      //}}AFX_MSG

      afx_msg void OnProcessSelChange();

      DECLARE_MESSAGE_MAP()
};


Source:

BEGIN_MESSAGE_MAP(CPropertyComboBox, CComboBox)
      //{{AFX_MSG_MAP(CPropertyComboBox)
      ON_WM_KILLFOCUS()
      ON_CONTROL_REFLECT(CBN_SELCHANGE,OnSelChange)
      //}}AFX_MSG_MAP

      ON_MESSAGE(WM_USER_PROCESS_SEL_CHANGE, OnProcessSelChange)

END_MESSAGE_MAP()


It works if I embed the control in a dialog or form but if I create it
inside an MSFlexGrid control it is not working!

Thanks
anti
0
 
NawalKishore1976Commented:
Hi There,

Handle the CBN_SELCHANGE in CPropertyComboBox class and then Generate one More Message (SendMessage)in this event.

Handle this event in the Dialog. Clear?

Nawal
0
 
antinutrinoAuthor Commented:
Hi again

I still cannot get this working in MSFlexgrid, I include here the full code for the class

Header.

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// PropertyComboBox.h : header file
//

#include "PropertyTabCtrl.h"

/////////////////////////////////////////////////////////////////////////////
// CPropertyComboBox window

class CPropertyComboBox : public CComboBox
{
// Construction
public:
      CPropertyComboBox();

// Attributes
public:

// Operations
public:

// Overrides
      // ClassWizard generated virtual function overrides
      //{{AFX_VIRTUAL(CPropertyComboBox)
      protected:
      //}}AFX_VIRTUAL

// Implementation
public:
      CPropertyTabCtrl* m_pTab;
      virtual ~CPropertyComboBox();

      // Generated message map functions
protected:
      //{{AFX_MSG(CPropertyComboBox)
      afx_msg void OnKillFocus(CWnd* pNewWnd);
      afx_msg void OnSelChange();
      //}}AFX_MSG

      afx_msg void OnProcessSelChange();

      DECLARE_MESSAGE_MAP()
};

// PropertyComboBox.cpp : implementation file
//

#include "stdafx.h"
#include "archive.h"
#include "PropertyComboBox.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

#include "PropertyGrid.h"

#define WM_USER_PROCESS_SEL_CHANGE WM_USER+0x300

/////////////////////////////////////////////////////////////////////////////
// CPropertyComboBox

CPropertyComboBox::CPropertyComboBox()
{
}

CPropertyComboBox::~CPropertyComboBox()
{
}


BEGIN_MESSAGE_MAP(CPropertyComboBox, CComboBox)
      //{{AFX_MSG_MAP(CPropertyComboBox)
      ON_WM_KILLFOCUS()
      ON_CONTROL_REFLECT(CBN_SELCHANGE,OnSelChange)
      //}}AFX_MSG_MAP

      ON_MESSAGE(WM_USER_PROCESS_SEL_CHANGE, OnProcessSelChange)

END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPropertyComboBox message handlers

void CPropertyComboBox::OnKillFocus(CWnd* pNewWnd)
{
      CComboBox::OnKillFocus(pNewWnd);
      
      // TODO: Add your message handler code here
      //AfxMessageBox("Kill Focus");
}

void CPropertyComboBox::OnSelChange()
{
      // TODO: Add your control notification handler code here
      AfxMessageBox("Doing Combo Sel Change");
      PostMessage(WM_USER_PROCESS_SEL_CHANGE);
}

void CPropertyComboBox::OnProcessSelChange()
{
      /*AfxMessageBox("Doing Combo Sel Change");

      CString strText;
      GetWindowText(strText);
      ((CPropertyGrid*) GetParent())->OnProcessInput(&strText);

      AfxMessageBox("Done Combo sel change.");*/
}


I can get the KillFocus event to be fired and caught but not the SelChange.

Help!

anti - depressed!
0
 
antinutrinoAuthor Commented:
sorry for not returning to this question, i have been away for sometime.

Thanks for the help.
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 3
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now