HI

I have a Tip of the day form that loads from a main form. The focus stays on the main form. Is there a way that I can switch the focus to the tip of the day form at runtime?

Tony

1. In the formload of your main form load tool tip as a dialog box. If you place this before anything else in the form load it will show before the main form.

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ToolTip.ShowDialog()
    End Sub

2. Same as above but use Show(me). This makes the tool tip a child of main form and you will be able to see and work on both.

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ToolTip.Show(Me)
    End Sub

3. Make your first form the tool tip and when you close it then load main form. To do this you must double click on the MyProject in solution explorer, toward the bottom you will see a dropdown box called "Shutdown Mode". Select "When last form closes". Now when tool tip closes the program won't end.

Public Class ToolTip

    Private Sub ToolTip_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        frmMain.Show()
    End Sub

End Class

If you plan on showing the tip of the day at any time while the program is running then you might consider using method 2 for that.

Hi Wayne

Iv'e tried your sugesstions and they work. I want both forms to be visible at the same time with the focus set to the tip of the day form. Some one showed me the following trick and it works:

Put a timer (timer1) on the form with enabled property = false, on form_load event add timer1.Enabled=true
On Timer1 event type the following:
Me.Focus()
Timer.Enabled=False

It may not be the best way to go but it works for me. Is there some kind of bug in vb 2005 when it comes to setting focus to a second form during runtime?

Thanks again

Tony

I don't know about a bug but I think it tells me wheather I have the focus or not. I think that if your program does not have the focus how is it going to set the focus. Which goes for the forms also in your program. The form you use to try to set the focus on another form actually has the focus.
Ramblings of an old man.

This article has been dead for over six months. Start a new discussion instead.