Click here to Skip to main content
15,909,051 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
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;
		
}


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
        }
Posted
Updated 17-May-11 5:44am
v4
Comments
Albert Holguin 17-May-11 10:37am    
edit: added pre tags
Rick Shaub 17-May-11 11:10am    
Those two code snippets arent doing the same thing. Should they be?
rsdreddim 17-May-11 11:56am    
Thanks Rick

wnd is not a pointer.its just regular System::windows::forms::COntrol object. so wnd. is giving me available function but not wnd->


also both snippets are doing the same thing returning/passing a usercontrol handler for the forms control window.
Rick Shaub 17-May-11 13:17pm    
I think you may want to change your method signature to all managed pointers except the int. Is the C++ code supposed to be an exact port of your C# code?
Mark Salsbery 17-May-11 14:28pm    
For reference types, yes...for value types, not necessarily.

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?
 
Share this answer
 
Comments
Rick Shaub 17-May-11 13:15pm    
My 5. OP needs to clarify intent. Your other points are valid as well.
Olivier Levrey 18-May-11 3:26am    
Thanks Rick.
Control.Handle is an IntPtr, not an IntPtr^

That makes your return type and xyz's type incorrect in your code.
 
Share this answer
 
Comments
Olivier Levrey 17-May-11 13:09pm    
The type is incorrect, it is true, but the important thing in OP's error is the Handle property is readonly and hence cannot be assigned.
Mark Salsbery 17-May-11 13:13pm    
Good point, thanks. I was going off the C# code claimed to work. Not sure what the deal is with the C++ code...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900