Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9020903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:07:54+00:00 2026-06-16T05:07:54+00:00

I have a dll which accepts HWND, (code in the dll); void VideoCapture::SetVideoWindow(HWND VidWind)

  • 0

I have a dll which accepts HWND,
(code in the dll);

void VideoCapture::SetVideoWindow(HWND VidWind)
{
    VideoWindow = VidWind;
}

i am calling the above dll in a sample c#.net application by adding the dll in references, in c#.net i have a form with Panel, is it possible to pass that panel to the dll?
i gave code as below in c#

VidCapWrapper.ManagedVideoCapture cc = new VidCapWrapper.ManagedVideoCapture();

cc.SetVideoWindow( panel1);

i am getting errors as below:
‘Error 2 The best overloaded method match for ‘VidCapWrapper.ManagedVideoCapture.SetVideoWindow(HWND__)’ has some invalid arguments D:\DirectShow_Capture_GUI\DirectShow_Capture_GUI\Form1.cs 44 13 DirectShow_Capture_GUI
Error 3 Argument 1: cannot convert from ‘System.Windows.Forms.Panel’ to ‘HWND__
‘ D:\DirectShow_Capture_GUI\DirectShow_Capture_GUI\Form1.cs 44 32 DirectShow_Capture_GUI`

Can any one please tell me how to pass panel to dll, (any example will be good)?
(sorry i am very new to .net, but trying to create a sample app which shows available devices like integrated webcam… and then shows preview on c#.net form panel)

EDIT:
Thanks to Both @Blachshma and @Hans Passant, Now i am able to pass c# windows form’s panel to my c++ dll.

I changed my func in dll as

void VideoCapture::SetVideoWindow(IntPtr windowHandle)
{
    VideoWindow = (HWND)windowHandle.ToPointer();
}

and in c# i am calling it as
cc.SetVideoWindow(panel1.Handle);

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T05:07:55+00:00Added an answer on June 16, 2026 at 5:07 am

    You must be careful to not expose fundamentally unmanaged types like HWND to C# code. The C# compiler will not allow you to pass a value of such a type. The proper interop type here is IntPtr, it can store a handle value. So make your C++/CLI method look like this:

    void VideoCapture::SetVideoWindow(IntPtr windowHandle)
    {
        VideoWindow = (HWND)windowHandle.ToPointer();
    }
    

    You can now simply pass panel1.Handle to the method, also of type IntPtr.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a dll which is based on .net 3.5 -- it uses internally
I have a dll which accepts a struct that contains a pointer to a
I have an older app (ca. 2005) which accepts dll plugins. The app was
So I have this C .dll source code which I want to use in
I have a DLL which has a function which accepts a function pointer converts
I have a .NET dll which wraps SQL data base to query the data
I have a dll which procedure accepts: const buffer parameter. There is also an
I have a dll which exports the interface class Qwe{ virtual void a() =
I have a Dll which is added into another solution now my code for
I have dll which accepts Pointer to array of bytes from C++ and try

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.