简体   繁体   English

错误 C2440:“static_cast”:无法从“void (__thiscall Visualizza::*)(char [])”转换为“AFX_PMSG”

[英]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.

相关问题 C2440 static_cast无法从基类转换为派生类 - C2440 static_cast cannot convert from base class to derived class 错误C2440:'=':无法从'const char [2]'转换为'char' - error C2440: '=' : cannot convert from 'const char [2]' to 'char' 错误C2440:&#39;=&#39;:无法从&#39;char [5]&#39;转换为&#39;char [20]&#39; - error C2440: '=' : cannot convert from 'char [5]' to 'char [20]' 错误 C2440 '<function-style-cast> ': 无法从 'char' 转换为 'std::string'</function-style-cast> - Error C2440 '<function-style-cast>': cannot convert from 'char' to 'std::string' 错误C2440:“ =”:无法从“ int”转换为“ char [5]” - error C2440: '=' : cannot convert from 'int' to 'char [5]' C2440:“ =”:无法从“ const char [9]”转换为“ char *” - C2440: '=': cannot convert from 'const char [9]' to 'char*' 错误 3 错误 C2440:“正在初始化”:无法从“void *”转换为“Socket *” - Error 3 error C2440: 'initializing' : cannot convert from 'void *' to 'Socket *' 在字符错误 C2440 中转换 LPVOID:= - convert LPVOID IN CHAR ERROR C2440: = c ++:错误C2440:“ <function-style-cast> &#39;:无法从&#39;A转换 <TYPE> &#39;至&#39;B <TYPE> &#39; - c++:error C2440: '<function-style-cast>' : cannot convert from 'A<TYPE>' to 'B<TYPE>' 错误C2440:&#39;type cast&#39;:无法从&#39;overloaded-function&#39;转换为&#39;HOOKPROC&#39; - error C2440: 'type cast' : cannot convert from 'overloaded-function' to 'HOOKPROC'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM