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 7528705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:27:19+00:00 2026-05-30T04:27:19+00:00

I am trying to integrate Winforms with a SharpDX project, in order to use

  • 0

I am trying to integrate Winforms with a SharpDX project, in order to use Winforms (and eventually WPF via HostElement) in my 3D app.

I need to create or configure a Control or Form such that I can:

a. Render it to a texture (that I can display as a sprite*)
b. Filter its input to remove mouse/keyboard events when the control is not active.

I have tried subclassing Control and Form, to override the OnPaint and OnPaintBackground but these have no effect on the child controls – or for that matter the forms borders (and even if they did they are not sufficient on their own as I am still left with a white square where I presume the ‘parent’ has been drawn).

How can I stop a Control or Form painting to the screen and instead draw only to a bitmap? (Is there some way I can override Graphics before the tree is painted, for example?)

*It needs to be done this way (as opposed to letting the control render to the screen) as Winforms doesn’t support true transparency, so I need to clip colour coded pixels in my pixel shader.

(To confirm, I don’t mean a DirectX texture specifically – I am happy with (in fact would prefer) a simple System.Drawing Bitmap)

  • 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-30T04:27:20+00:00Added an answer on May 30, 2026 at 4:27 am

    Here is one way to start going about it:

    • Create a derived control class so that we can expose InvokePaint which is protected
    • Call our custom method to get the Control’s image
    • Test form needs a picture box and an instance of Mybutton

    using System;
    using System.Drawing;
    using System.Windows.Forms;
    
    namespace WindowsFormsApplication1
    {
        public partial class Form1 : Form
        {
            public Form1() { InitializeComponent(); }
    
            private void Form1_Load(object sender, EventArgs e)
            {
                // create image to which we will draw
                var img = new Bitmap(100, 100);
    
                // get a Graphics object via which we will draw to the image
                var g = Graphics.FromImage(img);
    
                // create event args with the graphics object
                var pea = new PaintEventArgs(g, new Rectangle(new Point(0,0), new Size(100,100)));
    
                // call DoPaint method of our inherited object
                btnTarget.DoPaint(pea);
    
                // modify the image with algorithms of your choice...
    
                // display the result in a picture box for testing and proof
                pictureBox.BackgroundImage = img;
            }
        }
    
        public class MyButton : Button
        {
            // wrapping InvokePaint via a public method
            public void DoPaint(PaintEventArgs pea)
            {
                InvokePaint(this, pea);
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to integrate a new WPF control into an existing WinForms application and
I'm trying to integrate a WinForms Form inside a WPF XAML page. I have
Im trying to integrate a toolwindow in a Winforms application, it will be a
I am trying to use System.Net.WebClient in a WinForms application to upload a file
I'm trying integrate spring with hibernate but catch exception on project start. Caused by:
I'm trying to integrate a Facebook send button into my site using Facebook app.
I am trying to integrate OpenFeint 2.12.5 into my app. I already read this
I am trying to integrate facebook with android mobile, all i need to do
I'm trying to integrate the Moneris Hosted Pay Page into my .net 1.1 app
I'm trying to integrate sitemesh into my struts2 app, but i'm finding that it's

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.