Pregunta

I currently have a login form that is launched in a separate thread when the main application launches. I tried setting the TopMost property on the login form but it still does not work. I don't want to use the Application.Run method since I am dealing with several types of login forms and I just create an interface. The code below has been simplified:

UPDATE: This was the way the Login window was designed. I cannot change this. This worked in Windows XP, but does not work in Windows 7.

private void FormLoad()
{
  ParameterizedThreadStart threadStart = delegate {
                                 BeginLogin(_loginResults);
                                 };
  var thread = new Thread(threadStart);
  thread.Start();
}

private void BeginLogin(LoginResults callback)
{
  LoginData loginData = GetLoginData();

  if (callback != null)
    callback(loginData);
}

private LoginData GetLoginData()
{
  ILoginForm loginForm = LoginFormCreate();
  loginForm.TopMostDialog = true;  // This property sets the TopMost property.

  return loginForm.ShowLoginDialog();
}

No hay solución correcta

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top