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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:42:30+00:00 2026-05-15T14:42:30+00:00

I have a winforms application that doesn’t really have a main form – it’s

  • 0

I have a winforms application that doesn’t really have a main form – it’s just a simple file handling tool so it doesn’t really need one.

When the application starts, first an OpenFileDialog is used to select a file. Then, a dialog box is shown using Showdialog() with some options for how the selected file should be processed. Finally, a progress bar form is displayed whilst the file is operated on, and the application exits.

The problem is that when I’m debugging from Visual Studio, the middle form doesn’t get shown on top of other open windows, such as Visual Studio itself. When I run the compiled executable however it seems to work fine.

Usually, when ShowDialog results in a dialog that comes up behind, the solution is to use the Showdialog(owner) call, except as I don’t have a main form to speak of I don’t have an owner to set.

So, how can I make the dialog box come up on top of other windows in the same way that the OpenFileDialog automatically does?

  • 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-15T14:42:31+00:00Added an answer on May 15, 2026 at 2:42 pm

    I know exactly what you’re talking about and the problem is actually with the design of your app disagreeing with the way windows handles the focus. Windows has done this type of thing since win31. It’s like a land grab; if you show a window from your app, then hide/disable it, You snooze, you lose according to Bill. The fix: you need a main window! Or switch OS. Just because it works from an EXE doesn’t mean it will work when one of your users kicks it off from a batchfile or other than explorer.

    You CAN kludge your way out of this – run 3 separate exes; try running on 3 Application.Run threads in your sub Main; use to SetTopMost, AppActivate yourself.

    Or look up how to cause your app to grab the input focus using SDK calls – which successive versions of windows have made difficult in order to mitigate obnoxious apps using it (hence an app that could do this in w98 will flash the taskbar orange in xp) – and then programmers have worked around that of course. You could do that.

    But you’d be doing it wrong. A refactor is in order and change in stragegy for future apps. This is not a decision I made; the way windows works is set in stone, plus the way users expect it to work is set in millions of brains, which is harder than stone – swim with the flow!

    Easy refactor with no real impact:

    • Back up your project (or shelve a copy in TFS)
    • In your options dialog, cut all your controls. Put in a form-sized panel named pnlOpts. Paste them back.
    • Make that form your main form.
    • In the form_shown, set pnlOpts.Visible=false, or just default it that way (you can show another panel w/ the app name or a background image if you want to be a little trashy 😉
    • Call the setup code that also shows the file dlg from this area as well
    • Set your file dlg to have that form as parent, startup position as center-parent (I mean owner not parent). Remember cancel from this = close the settings form
    • When this is done, show pnlOpts.
    • In the OK button, call the code that does the progress bar. You can hide or disable pnlOpts here again.
    • At no point can you hide, set Visible=false, or enabled=false on the ENTIRE window or you will invoke windows’ focusing wrath (which is the cause of your misery here).

    The real key here, the one-line answer: leave a main window visible and enabled at all times, if you want to disable its functionality, just gray or hide all its controls. this is easiest to do with the panel. You can show the user other panels or images to entertain them if you want (especially if graying [.enabled=false] the content doesn’t make sense).

    You won’t like that way that looks, or you’d have built it like that to begin with, but millions of lines of windows code and millions of brains of windows users are passive-agressively disagreeing with you right now!

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

Sidebar

Ask A Question

Stats

  • Questions 488k
  • Answers 488k
  • 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 Processing images on the iPhone with any kind of speed… May 16, 2026 at 8:35 am
  • Editorial Team
    Editorial Team added an answer Matrix::minor(0, j) returns a matrix of size (N-1, N-1). Calling… May 16, 2026 at 8:35 am
  • Editorial Team
    Editorial Team added an answer I can't explain this in detail. But this is indeed… May 16, 2026 at 8:35 am

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

No related questions found

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.