Controlling Focus when two forms are open

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • genojoe

    #1

    Controlling Focus when two forms are open

    I have a form with an RTF control and I want to use a subform to do "Find and
    Replace". Beyond that, I want the subForm to always be on Top when the
    Parent form has focus but have it not be on top if neither the subform nor
    parent form have focus.

    The code that I think should do this is the following. Unfortunately, with
    this code, the subForm retains focus. (Me.Focus() is ignored) Is there a
    way to have the subform be on top but have the Parent form gain focus?

    Private Sub MyForm_Activate d(......) Handles MyBase.Activate d
    If Not Me.mfrmFindRepl ace Is Nothing Then
    Me.mfrmFind.Top Most = True
    Me.Focus()
    End If
    End Sub

  • Herfried K. Wagner [MVP]

    #2
    Re: Controlling Focus when two forms are open

    "genojoe" <genojoe@discus sions.microsoft .com> schrieb:[color=blue]
    >I have a form with an RTF control and I want to use a subform to do "Find
    >and
    > Replace". Beyond that, I want the subForm to always be on Top when the
    > Parent form has focus but have it not be on top if neither the subform nor
    > parent form have focus.[/color]

    \\\
    Dim f As New ToolForm()
    f.Owner = Me
    f.Show()
    ///

    --
    M S Herfried K. Wagner
    M V P <URL:http://dotnet.mvps.org/>
    V B <URL:http://classicvb.org/petition/>

    Comment

    • genojoe

      #3
      Re: Controlling Focus when two forms are open

      Thank you. Problem solved. Besides adding the Owner property. I also
      needed to remove the f.TopMost = True statement..

      "Herfried K. Wagner [MVP]" wrote:
      [color=blue]
      > Dim f As New ToolForm()
      > f.Owner = Me
      > f.Show()[/color]

      Comment

      Working...