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

  • SEARCH
  • Home
  • 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 7521307
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:12:51+00:00 2026-05-30T02:12:51+00:00

I am using DirectShow .NET to display video in a control in a C#

  • 0

I am using DirectShow .NET to display video in a control in a C# form. I require to have the video to fill the control when the form and thus control is made bigger/smaller (the if branch of MainForm_ResizeMove handles this). I also require to maintain the source video size if a property is set. The code in the else section of MainForm_ResizeMove handles this. The problem I have is while the else section positons my video in the correct postion centered on the control, the background is grey. As I have set the video position to the size of the video then the border colour is not applied (as there is no border in this case). Can someone advise what the best solution would be?

private IVMRWindowlessControl9 windowlessCtrl = null;

...
private void MainForm_Paint(object sender, PaintEventArgs e)
    {           
        if (windowlessCtrl != null)
        {
            IntPtr hdc = e.Graphics.GetHdc();
            int hr = windowlessCtrl.SetBorderColor(0x00FFFFFF);
            hr = windowlessCtrl.RepaintVideo(this.Handle, hdc);
            e.Graphics.ReleaseHdc(hdc);
        }
    }

    private void MainForm_ResizeMove(object sender, EventArgs e)
    {
        if (windowlessCtrl != null)
        {
            if (fillScreen || (this.ClientRectangle.Width < streamFrameWidth) || (this.ClientRectangle.Height < streamFrameHeight))
            {
                int hr = windowlessCtrl.SetVideoPosition(null, DsRect.FromRectangle(this.ClientRectangle));
            }
            else
            {
                Rectangle rect = new Rectangle((this.ClientRectangle.Width / 2) - (streamFrameWidth / 2), 
                                               (this.ClientRectangle.Height/ 2) - (streamFrameHeight / 2), 
                                                streamFrameWidth, streamFrameHeight);
                int hr = windowlessCtrl.SetVideoPosition(null, rect);  
            } 
        }
    }
  • 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-05-30T02:12:51+00:00Added an answer on May 30, 2026 at 2:12 am

    It was infact simple, set the background colour of the control to black!!

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

Sidebar

Related Questions

I have a control, VideoControl, which displays video using DirectShow - it's set as
Using ASP.NET MVC there are situations (such as form submission) that may require a
I have a project where I need to record a video using DirectShow from
How to turn Sequence of images into video using DirectShow filters? I have image
I am using a DirectShowLib which is a thin wrapper for DirectShow. I have
Using online interfaces to a version control system is a nice way to have
Hi I want to convert the code at Webcam using DirectShow.NET to C#. It
I currently have a DirectShow.NET graph that properly plays but I would like it
I am playing video using custom allocator using directshow. I want to set brightness,
I want to create a project using DirectShow. Which license does DirectShow have? Can

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.