[英]error C2440: 'static_cast' : cannot convert from 'void (__thiscall Visualizza::* )(char [])' to 'AFX_PMSG'
Can someone help me?有人能帮我吗? I'm doing an MFC application via VS 2010 ultimate.
我正在通过 VS 2010 Ultimate 执行 MFC 应用程序。 ps.
附言。 im new withth c++.
我是新的 c++。 This application is for print on a combox filenames.
此应用程序用于在组合框文件名上打印。
this is the.cpp file这是.cpp文件
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这是.h文件
#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;
};
Registering notification handlers is explained in the Remarks section of the CComboBox
documentation. CComboBox
文档的备注部分解释了注册通知处理程序。 In particular, the following needs to be followed:特别是,需要遵循以下几点:
The parent's function prototype is as follows:
父级的function原型如下:
afx_msg void memberFxn( );
In other words: Your user-supplied notification handlers cannot take any arguments.换句话说:您的用户提供的通知处理程序不能采用任何 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.使其与
ON_CBN_SELCHANGE(IDC_COMBO1, &Visualizza::OnCbnSelchangeCombo1)
消息 map 条目兼容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.