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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T00:59:58+00:00 2026-05-15T00:59:58+00:00

I have a borderless Windows Forms application. The main window creates other forms (simple

  • 0

I have a borderless Windows Forms application.

The main window creates other forms (simple dialogs where I can click yes or no) with ShowDialog().
Every created dialog is not visible in the taskbar, my application has only one taskbar entry that focuses my application (and if a dialog is open that one is focused). If I use ALT + TAB to cycle to all open windows I only see one entry, too.

However, if the dialog is created while my application doesn’t have the focus (for example the user starts a long running task, starts to work on something else and while being in the background, my application shows a dialog “Task done…”) and I want to go back to my application, things are getting strange.

  • If I click on the taskbar to focus my application, the main window is focused (not the dialog).
  • I can’t use the main window (because there is still an open modal dialog).
  • Windows 7 ALT + TAB preview shows the Dialog while the taskbar mouseover preview shows the main window (in normal behavior both show the dialog in front of the main window).
  • The only way to make my application usable again is to ALT + TAB to the entry and close the modal dialog.
  • If I use ALT + TAB only the dialog is brought to the front and the main window is still in the background.

Is there a way to prevent that from happening?
I know what to do, but most customers think the application crashed since the main window doesn’t respond.

Update:

The solution is to pass the top level window to the ShowDialog() method (in most cases and if used in a form that would be the “this”).

Since I didn’t wanted to refactor my entire code, and all my forms inherit from “MyCustomFormBase” here is a little solution that works very well.

Public Class MyCustomFormBase

    Public Shared Property ApplicationMainForm() As Form
        Get
            Return _applicationMainform
        End Get
        Set(ByVal value As Form)
            _applicationMainform = value
        End Set
    End Property
    Private Shared _applicationMainform As Form

    Public Shadows Function ShowDialog() As DialogResult
        If MyCustomFormBase.ApplicationMainForm IsNot Nothing Then
            Return MyBase.ShowDialog(MyCustomFormBase.ApplicationMainForm)
        Else
            Return MyBase.ShowDialog()
        End If
    End Function

    Public Shadows Function ShowDialog(ByVal owner As IWin32Window) As DialogResult
        Return MyBase.ShowDialog(owner)
    End Function

End Class

In the constructor of the main window I use

MyCustomFormBase.ApplicationMainForm = Me

once. It helped me half a day refactoring 😉

  • 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-15T00:59:58+00:00Added an answer on May 15, 2026 at 12:59 am

    Have you tried passing a reference to the main window to ShowDialog calls?

    // assuming this code is in the main form (so "this" refers to the main form)
    DialogForm dialog = new DialogForm();
    DialogResult result = dialog.ShowDialog(this);
    

    Quote from the documentation of this overload:

    This version of the ShowDialog method
    allows you to specify a specific form
    or control that will own the dialog
    box that is shown. If you use the
    version of this method that has no
    parameters, the dialog box being shown
    would be owned automatically by the
    currently active window of your
    application.

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

Sidebar

Ask A Question

Stats

  • Questions 530k
  • Answers 530k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer It's exactly the same with NHibernate 3; just replace dataContext.Tweets… May 16, 2026 at 11:31 pm
  • Editorial Team
    Editorial Team added an answer post_max_size and upload_max_filesize are PHP.ini settings. You can set them… May 16, 2026 at 11:31 pm
  • Editorial Team
    Editorial Team added an answer Not yet fully optimized: public static void main(String... a) {… May 16, 2026 at 11:31 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have a C# WinForms borderless window, for which I override WndProc and handle
I have a borderless and transparent window in WPF, with some fancy decoration at
I have a borderless form which is always on top and with WS_EX_NOACTIVATE flag
I wrote an attached property that I can set on a window to extend
I have a window that does not have a title bar ( WindowStyle ==
I need a WeifenLuo replacement that'll run on both .NET and Mono, on Windows,
I have made a TForm derivative that acts like the drop down part of
Have noticed issue while testing iphone app that if one quickly opens/dismisses a modal
Have I correctly added an element to a hashTable? Flows flows = new Flows(sIP,dIP);
Have you seen library for flexible working with terminal(Unix like)? I want to implement

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.