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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:50:11+00:00 2026-06-14T13:50:11+00:00

Fixing third party controls that use user32.dll public partial class Form1 : Form {

  • 0

Fixing third party controls that use user32.dll

public partial class Form1 : Form
{
    TheForm theForm;//empty form
    public Form1()
    {
        InitializeComponent();
        theForm = new TheForm();
    }

    internal const int SWP_SHOWWINDOW = 0x0040;

    [DllImport("user32.dll", CharSet = CharSet.Auto)]
    internal static extern int ShowWindow(IntPtr hWnd, short cmdShow);        

    private void button1_Click(object sender, EventArgs e)//shows theForm when it wants to
    {
        ShowWindow(theForm.Handle, SWP_SHOWWINDOW);
    }

    private void button2_Click(object sender, EventArgs e)//shows theForm always
    {
        theForm.Show();
    }
}

Why after call user32 ShowWindow, most of times window “stuck in limbo”?
It captures losing of focus and disposes, but doesn’t capture mouse events and doesn’t paint itself.

  • 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-14T13:50:12+00:00Added an answer on June 14, 2026 at 1:50 pm

    Im no expert, but i think you need to show your form by calling a Show() method outside of the button click event handler methods. if theres no form to see, you cant click a button to show the form.

    Im not sure theres a reason to use user32.dll in C# to make winforms applications. Because this is done for you by C#, in a mannor of speaking.

    All you need to do is allow visual studio to create the form code for you in the drag and drop forms designer. Then to show and use your form without creating a new source file just for your Main() method, just write the Main() method right there in the generated code.

    Heres a great article about using the windows forms designer.

    http://msdn.microsoft.com/en-us/library/360kwx3z(v=vs.90).aspx

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

Sidebar

Related Questions

I use quite a lot third party libraries which have many warnings in it,
Third try at fixing this tonight - trying a different approach than before now.
I am fixing up someone else's code and noticed that the person calls LoadLibrary
I am working on fixing a bug in VB that is giving this error.
I am working on mobile compatibility of a site for my third party product,
I'm writing a program to parse some third-party XML files. The structure is something
When fixing defects in new code what are the best strategies to use? cause
I've been recently fixing my application that apparently reached some GA quota limitations and
I was bug-fixing some code and the compiler warned (legitimately) that the function dynscat()
I'm working on a Python application which uses a number of open source third-party

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.