7 Replies - 435 Views - Last Post: 22 August 2012 - 06:52 AM Rate Topic: -----

#1 the5thelement  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 39
  • Joined: 30-July 12

Form does not receive focus.

Posted 21 August 2012 - 01:10 PM

I am writing an update program for a game I am making. However when I tell the from to show a form it does not put the form in the front of the previous form. I have tried using
Public Sub Form3_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Me.BringToFront()
    End Sub

but it still shows it behind the first form. I have also tried
Public Sub CheckForUpdate()
        Dim PatchVersionRequest As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create("https://dl.dropbox.com/u/99076080/Launcher%20Updater/Patch%20Version.txt")
        Dim PatchVersionResponse As System.Net.HttpWebResponse = PatchVersionRequest.GetResponse()
        Dim PatchVersionStream As System.IO.StreamReader = New System.IO.StreamReader(PatchVersionResponse.GetResponseStream())
        Dim PatchVersion As String = PatchVersionStream.ReadToEnd
        Dim CurrentPatchVersionStream As System.IO.StreamReader = New System.IO.StreamReader(My.Computer.FileSystem.CurrentDirectory & "/Launcher.wtf")
        Dim CurrentPatchVersion As String = CurrentPatchVersionStream.ReadToEnd
        If PatchVersion = CurrentPatchVersion * 2 Then
            [u][b]Form3.Show()[/b][/u]
            Form3.TextBox1.Text = "Update"
            Form3.Label1.Text = "Updating Patch-T.MPQ"
            [b][u]Form3.BringToFront()[/u][/b]
        Else
            PictureBox1.Enabled = True
        End If
    End Sub


But still it shows the third form behind the first form. Is there anyway around this?

Is This A Good Question/Topic? 0
  • +

Replies To: Form does not receive focus.

#2 m_wylie85  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 93
  • View blog
  • Posts: 871
  • Joined: 15-October 10

Re: Form does not receive focus.

Posted 21 August 2012 - 01:43 PM

have to tried hiding the previous form e.g:

frmform2.show()
me.hide()

Was This Post Helpful? 0
  • +
  • -

#3 brutalexcess  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 6
  • Joined: 30-July 12

Re: Form does not receive focus.

Posted 21 August 2012 - 01:48 PM

Try the above, or alternatively you may also try:

nForm.ShowDialog() 'Shows the form as a dialog, forcing it to become the focused form.



Depending on what how you are trying to use your forms, a dialog may be an alternative. This however requires that form to be closed before you can access other forms due to the behaviour of dialogs.
Was This Post Helpful? 0
  • +
  • -

#4 the5thelement  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 39
  • Joined: 30-July 12

Re: Form does not receive focus.

Posted 21 August 2012 - 01:58 PM

I have tried the
Form3.Show
Me.Hide
method but the first form wont even hide.
Was This Post Helpful? 0
  • +
  • -

#5 m_wylie85  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 93
  • View blog
  • Posts: 871
  • Joined: 15-October 10

Re: Form does not receive focus.

Posted 21 August 2012 - 02:03 PM

so when you open the third form that would mean you would need to hide two form ? so try explicitly telling form one and two to hide.
Was This Post Helpful? 0
  • +
  • -

#6 the5thelement  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 39
  • Joined: 30-July 12

Re: Form does not receive focus.

Posted 21 August 2012 - 03:05 PM

Still does not work Form1 is still visible.
Was This Post Helpful? 0
  • +
  • -

#7 brutalexcess  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 6
  • Joined: 30-July 12

Re: Form does not receive focus.

Posted 22 August 2012 - 05:57 AM

Try this:

For Each frm As Form In My.Application.OpenForms
            If frm.Name = "Form1" Then
                frm.Hide()
            End If
        Next


Was This Post Helpful? 1
  • +
  • -

#8 ToshNeox  Icon User is offline

  • D.I.C Head

Reputation: 8
  • View blog
  • Posts: 100
  • Joined: 10-December 11

Re: Form does not receive focus.

Posted 22 August 2012 - 06:52 AM

Does form 3 need to be constantly on top of all the other forms? If so, you could try the TopMost attribute.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1