Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/137.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 如何让事件处理程序访问成员数据?_C++_.net_Delegates - Fatal编程技术网

C++ 如何让事件处理程序访问成员数据?

C++ 如何让事件处理程序访问成员数据?,c++,.net,delegates,C++,.net,Delegates,给出了错误: 1> .\Form1.cpp(26):错误C3352:“无效Form1::DownloadProgressCallback(System::Object^,System::Net::DownloadProgressChangedEventArgs^)”:指定的函数与委托类型“无效(System::Object^,System::Net::DownloadProgressChangedEventArgs^)”不匹配 文档使用静态非成员函数作为此委托参数,但我想更新Form1类的进度条

给出了错误:

1> .\Form1.cpp(26):错误C3352:“无效Form1::DownloadProgressCallback(System::Object^,System::Net::DownloadProgressChangedEventArgs^)”:指定的函数与委托类型“无效(System::Object^,System::Net::DownloadProgressChangedEventArgs^)”不匹配

文档使用静态非成员函数作为此委托参数,但我想更新
Form1
类的进度条成员。我做错了什么


我使用的是.NET 2.0,因此请尽可能使语言过时。

将对象传递给委托构造函数

         myWebClient->DownloadProgressChanged += gcnew DownloadProgressChangedEventHandler( &Form1::DownloadProgressCallback );

将对象传递给委托构造函数

         myWebClient->DownloadProgressChanged += gcnew DownloadProgressChangedEventHandler( &Form1::DownloadProgressCallback );

成员函数的委托将被声明(在表单中):


基本上,第一个参数是定义成员函数的对象。在这种情况下,
这个
应该可以工作。

成员函数的委托将被声明(在表单中):

基本上,第一个参数是定义成员函数的对象。在这种情况下,
这个
应该可以工作

 myWebClient->DownloadProgressChanged += gcnew DownloadProgressChangedEventHandler(this,  &Form1::DownloadProgressCallback );