Embed Video Screen to Panel c#

Hello,

I want to embed screen video to winforms in visual studio c#. if it possible please help.

Thank you.

@vimlesh1975 many years ago published a code snippet to get the handle of the screen-consumer window and attach it to a panel. The code was in VB.NET but could be translated to C# easy.

Thank you for your Quick Reply.
I will contact to vimkesh1975.

Client is shared with source code. It is in vb dot net.

I got a working code for this in C#

https://drive.google.com/file/d/1x_N01-ECAUW1M8ZxJrgNCtCeS31Tuq2O/view?usp=sharing

using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace WindowsFormsApp1
{
    public partial class Form1 : Form
    {
        Process parentedProcess;
        public Form1()
        {
            InitializeComponent();
        }
        private void Cmdshowcasparcgwindow_Click(object sender, EventArgs e)
        {
            try
            {
                Process[] p1 = Process.GetProcessesByName("casparcg");
                int iprocess;
                for (iprocess = 0; iprocess <= p1.GetUpperBound(0); iprocess++)
                {
                    if (p1[iprocess].MainWindowTitle == cmbcasparcgwindowtitle.Text)
                        break;
                }
                parentedProcess = p1[iprocess];
                SetParent(parentedProcess.MainWindowHandle, Panel1.Handle);
                SendMessage(parentedProcess.MainWindowHandle, 274, 61488, 0);
            }
            catch (Exception ex)
            { }
        }
        [DllImport("user32.dll")]
        static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);

        [DllImport("user32.dll")]
        static extern IntPtr SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
        private void Cmdoutcasparcgwindow_Click(object sender, EventArgs e)
        {
            try

            { SetParent(parentedProcess.MainWindowHandle, (IntPtr.Zero)); }
            catch (Exception ex)
            { }
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            
        }

        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        { try

            { SetParent(parentedProcess.MainWindowHandle, (IntPtr.Zero)); }
            catch (Exception ex)
            { }
        }
    }
}


1 Like

Thank you very much.