C ++用户控件和Intptr上的C2039错误 [英] C2039 error on C++ user control and Intptr

查看:77
本文介绍了C ++用户控件和Intptr上的C2039错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

System::IntPtr^ LiveViewClass::LiveView(System::Windows::Forms::Control wnd, String^ CameraIP, EventArgs e, int i){
		
	System::IntPtr^ xyz;
	DisplayWnd^ l_hwnd = gcnew DisplayWnd();//is a usercontrol object
	    	
	
//option 1:
l_hwnd->Handle = wnd.Handle; //error here
return l_hwnd->Handle;
	
//option 2:

        xyz = wnd.Handle;
	l_hwnd->Handle = xyz; // error here	
	return l_hwnd->Handle;
		
}



我正在使用dll来传递窗口处理程序以显示视频..

在我的liveview函数中,我将usercontrol传递给窗口处理程序对象,这给了我一个错误"set:不是''System :: Windows :: Forms :: COntrol :: Handle''的成员." >
当我在C#中执行相同的操作时,效果很好



I am working on a dll to pass a window handler to display the video..

In my liveview function I am passing the usercontrol to window handler object and this is giving me an error "set: is not a member of ''System::Windows::Forms::COntrol::Handle''".

This worked well when I did the same in C#

public IntPtr LiveView(System.Windows.Forms.Control wnd, String CamIP, EventArgs e, int i)
        {
            l_hwnd1 = new DisplayWnd();
            l_hwnd1.Parent = wnd;
            

            IntPtr ret = l_hwnd1.Handle;

            return ret;
            //return Image or Stream
        }

推荐答案

首先,应按照Mark的说明,将IntPtr^替换为IntPtr.
其次,Handle属性是 readonly ,您不能分配它.

为什么要更改窗口句柄,您的目的是什么?
First you should replace IntPtr^ by IntPtr as Mark told you.
Second, the Handle property is readonly, you can''t assign it.

Why do you want to change the window handle, what is your aim?


Control.Handle是一个IntPtr,而不是IntPtr ^

这会使您的返回类型和xyz的类型在您的代码中不正确.
Control.Handle is an IntPtr, not an IntPtr^

That makes your return type and xyz''s type incorrect in your code.


这篇关于C ++用户控件和Intptr上的C2039错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆