Focusing problem on windows form

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

    Focusing problem on windows form

    I have a question about the focusing on windows form control. First of all,
    I have a main windows form (MainFrm) for my application, another form
    (NewFrm) will be displayed if pressing one of the button on the MainFrm. I
    used the NewFrm.Show() method to open the form. However, if I switch the
    focus to another applcation (eg. Outlook, IE etc) and then switch back to my
    application program. I lost the focus on NewFrm and MainFrm display on top
    instead occasionally. I need to use the function key ctrl + tab in order to
    get back the focus on NewFrm.

    All I want to know is there any method can let my application program always
    focus on NewFrm after switching back the focus from other application in
    task bar?


  • Steven

    #2
    Re: Focusing problem on windows form

    sorry, I mean Alt + Tab instead of Ctrl + Tab

    "Steven" <a@a.com> wrote in message
    news:%23uX3o%23 mPGHA.3944@tk2m sftngp13.phx.gb l...[color=blue]
    > I need to use the function key ctrl + tab in order to get back the focus
    > on NewFrm.
    >[/color]


    Comment

    • Virgil

      #3
      Re: Focusing problem on windows form

      You could try something like this:

      Private Sub Form1_Activated (ByVal sender As Object, ByVal e As
      System.EventArg s) Handles Me.Activated

      Dim AForm As Form

      For Each AForm In Application.Ope nForms
      If AForm.GetType Is Form2.GetType Then
      AForm.Focus()
      Return
      End If

      Next
      End Sub

      Comment

      • Steven

        #4
        Re: Focusing problem on windows form

        I can't find the Application.Ope nForms method. In addition, what is Form2?

        "Virgil" <vschleich@tril liumteam.com> wrote in message
        news:1141357707 .286555.187090@ t39g2000cwt.goo glegroups.com.. .[color=blue]
        > You could try something like this:
        >
        > Private Sub Form1_Activated (ByVal sender As Object, ByVal e As
        > System.EventArg s) Handles Me.Activated
        >
        > Dim AForm As Form
        >
        > For Each AForm In Application.Ope nForms
        > If AForm.GetType Is Form2.GetType Then
        > AForm.Focus()
        > Return
        > End If
        >
        > Next
        > End Sub
        >[/color]


        Comment

        Working...