Can someone help me? I'm doing an MFC application via VS 2010 ultimate. ps. im new withth c . This application is for print on a combox filenames.
this is the .cpp file
BEGIN_MESSAGE_MAP(Visualizza, CDialogEx)
ON_CBN_SELCHANGE(IDC_COMBO1, &Visualizza::OnCbnSelchangeCombo1)
END_MESSAGE_MAP()
// Visualizza message handlers
void Visualizza::OnCbnSelchangeCombo1(char util[20])
{
std::string s = util;
LPTSTR x = new TCHAR[s.size() 1];
stampa.AddString(x);
}
and this is the .h file
#pragma once
#include "afxwin.h"
// Visualizza dialog
class Visualizza : public CDialogEx
{
DECLARE_DYNAMIC(Visualizza)
public:
Visualizza(CWnd* pParent = NULL); // standard constructor
virtual ~Visualizza();
// Dialog Data
enum { IDD = IDD_DIALOG1 };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnCbnSelchangeCombo1(char util[20]);
CComboBox stampa;
};
CodePudding user response:
Registering notification handlers is explained in the Remarks section of the CComboBox
documentation. In particular, the following needs to be followed:
The parent's function prototype is as follows:
afx_msg void memberFxn( );
In other words: Your user-supplied notification handlers cannot take any arguments.
void Visualizza::OnCbnSelchangeCombo1(char util[20])
would need to be changed to
void Visualizza::OnCbnSelchangeCombo1()
to make it compatible with the ON_CBN_SELCHANGE(IDC_COMBO1, &Visualizza::OnCbnSelchangeCombo1)
message map entry.