0

I will jump right into the question. Basically I have set up a program that requires multiple message pumps. However, when a form is in focus and a form that is on a different message pump calls BringToFront, it won't work because it's on a different message pump. Is there any way to fix this?

Damn, I cannot believe I forgot to add that... I am sorry ya'll! Language: VB.NET Sample of code:

Public Class Form1
    Private Shared Test As New Form2

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Test.Invoke(Sub() Test.BringToFront())
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Dim T As New Threading.Thread(Sub()

                                          Application.Run(Test)
                                      End Sub)
        T.Start()
    End Sub
End Class

I use Invoke() because the form was created on a different thread.

First I press Button2, then I click Form1 again and try to bring Form2 to front using Button1.

Prionum
  • 133
  • 1
  • 2
  • 7
  • Welcome to SE. You may want to add details to your post (using `Edit`): Which language, sample of code to demonstrate the problem... See [ask] as a guideline. – mins Apr 10 '15 at 21:14

1 Answers1

0

You may want to use AttachThreadInput if you're running windows on different threads.

Robinson
  • 9,666
  • 16
  • 71
  • 115