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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:47:47+00:00 2026-05-26T18:47:47+00:00

I have an SDK in unmanaged code that I’m using in a .NET Winforms

  • 0

I have an SDK in unmanaged code that I’m using in a .NET Winforms GUI program. The SDK paints images on Panels that I pass in by handle to the SDK. However, it’s still a .NET control, contained within wholly managed GUI elements.

The problem I’m having is that when the main window gets redrawn, my program (and the .NET runtime) repaints these Panels, which happens after the unmanaged code redraws the image on the panel. That overwrites the image I expect with the “background” set up in the Designer.

After giving the panel to my SDK, I want to stop .NET repainting them. But, I need to keep the resizing behavior.

I tried the simple approach, which was to derive “MyPanel” from the Panel, adding custom code that controls the OnPaint() method:

public class MyPanel : Panel
{
    [Category("Behavior"), DefaultValue(true)]
    public bool LetNetPaint { get; set; }

    protected override void OnPaint(PaintEventArgs e)
    {
        if(LetNetPaint)
            base.OnPaint(e);
    }
}

This does not work, however.

I also tried intercepting the WM_PAINT and WM_ERASEBKGND messages in WndProc(), and that’s… better, but not great.

I’m at a loss; this simply must work or a lot of hard work goes down the drain and a lot of harder work begins to implement a different solution from scratch.

  • 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-26T18:47:48+00:00Added an answer on May 26, 2026 at 6:47 pm

    As the answer to my own question, here’s the code that ended up working, based on Hans Passant’s SetStyle suggestion:

    public class NativeDrawingPanel : Panel
    {
        private bool letNetPaint;
    
        [Category("Behavior"), DefaultValue(true)]
        public bool LetNetPaint
        {
            get { return letNetPaint; }
            set 
            { 
                letNetPaint = value;
                SetStyle(ControlStyles.UserPaint, value);
                if(value) Refresh();
            }
        }
    
        public NativeDrawingPanel()
        {
            letNetPaint = true;
            SetStyle(ControlStyles.UserPaint, true);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just installed the Platform SDK for Windows Server 2008 and .NET 3.5
I have created an Excel document using OpenXml SDK 2.0, now I have to
I currently have an app on the market that supports Android 1.5 (SDK level
I want to program for DirectX in C# and i have DirectX SDK, what
I am using a quickbooks sdk that containst the QBFC8Lib dll everything works fine
I have an SDK that is written primarily in C#. We have some native
I have a custom plugin for 3ds Max that interfaces with some managed code
Let's say we have an SDK in C++ that accepts some binary data (like
I have developed an application written in unmanaged C++ that makes use of OpenCV
I have an SDK for a USB device. It includes some installer for .NET

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.