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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T00:20:51+00:00 2026-05-19T00:20:51+00:00

My WinForms app has a simple modal login form, invoked at startup via ShowDialog().

  • 0

My WinForms app has a simple modal login form, invoked at startup via ShowDialog(). When I run from inside Visual Studio, everything works fine. I can just type in my User ID, hit the Enter key, and get logged in.

But when I run a release build directly, everything looks normal (the login form is active, there’s a blinking cursor in the User ID MaskedEditBox), but all keypresses are ignored until I click somewhere on the login form. Very annoying if you are used to doing everything from the keyboard.

I’ve tried to trace through the event handlers, and to set the focus directly with code, to no avail.

Any suggestions how to debug this (outside of Visual Studio), or failing that – a possible workaround?

Edit

Here’s the calling code, in my Main Form:

    private void OfeMainForm_Shown(object sender, EventArgs e)
    {
        OperatorLogon();
    }

    private void OperatorLogon()
    {
        // Modal dialogs should be in a "using" block for proper disposal
        using (var logonForm = new C21CfrLogOnForm())
        {
            var dr = logonForm.ShowDialog(this);

            if (dr == DialogResult.OK)
                SaveOperatorId(logonForm.OperatorId);
            else
                Application.Exit();
        }
    }

Edit 2

Didn’t think this was relevant, but I’m using Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase for it’s splash screen and SingleInstanceController support.

I just commented out the splash screen code, and the problem has disappeared. So that’s opened up a whole new line of inquiry…

Edit 3

Changed title to reflect better understanding of the problem

  • 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-19T00:20:52+00:00Added an answer on May 19, 2026 at 12:20 am

    I’ve found a hack…er…I mean…workaround, that fixes the problem. The solution was buried in one of the comments of this answer (thanks, P. Brian Mackey, for providing the link to the related question!)

    The workaround is to minimize the main window while the splash screen is displayed, then set it’s WindowState back to Normal before showing the login form.

    In the code below, see the lines commented with “HACK”.

    public class SingleInstanceController : WindowsFormsApplicationBase
    {
        public SingleInstanceController()
        {
            this.IsSingleInstance = true;
        }
    
        /// <summary>
        /// When overridden in a derived class, allows a designer to emit code that 
        /// initializes the splash screen.
        /// </summary>
        protected override void OnCreateSplashScreen()
        {
            this.SplashScreen = new SplashScreen();
        }
    
        /// <summary>
        /// When overridden in a derived class, allows a designer to emit code that configures 
        /// the splash screen and main form.
        /// </summary>
        protected override void OnCreateMainForm()
        {
            // SplashScreen will close after MainForm_Load completed
            this.MainForm = new OfeMainForm();
    
            // HACK - gets around problem with logon form not having focus on startup
            // See also OfeMainForm_Shown in OfeMainForm.cs
            this.MainForm.WindowState = FormWindowState.Minimized;
        }
    }
    
    
    public partial class OfeMainForm : Form
    {
        // ...
    
        private void OfeMainForm_Shown(object sender, EventArgs e)
        {
            // HACK - gets around problem with logon form not having focus on startup
            // See also OnCreateMainForm in Program.cs
            this.WindowState = FormWindowState.Normal;
    
            OperatorLogon();
        }
    
        // ...
    
    }
    

    This is working for now, but I’m wondering if I should explicitly open the Logon form from the SingleInstanceController, rather than from my main form.

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

Sidebar

Related Questions

I'm trying to write a simple Compact Framework winforms app. The main form has
I have an MDI WinForms app in which the MDI parent form has a
I have a winforms app and the main (and only) form has several buttons.
I have a Winforms app that has a DataGridView that is databound at runtime.
I have a DataGridView in a Winforms app that has about 1000 rows (unbound)
I have a C# winforms app with a form for user preferences. An admin
I'm migrating a WinForms app to WPF. Everything has gone well so far except
I have a C# .NET 2.0 WinForms app. My app has a control that
I developed a winforms app locally on my machine. It reads data from a
I started a new winforms project, fairly simple, has a few labels, text boxes,

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.