Focus after Splash Screen

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Allan Stead
    New Member
    • Jul 2007
    • 7

    #1

    Focus after Splash Screen

    When my splash screen auto closes, the program's main form has its title bar dark grey instead of the usual dark blue, and I have to click somewhere on the main form to give it focus.

    This problem doesn't show up when I run the program from within VB Express, but only after I've published to my own computer (to get easier access to the .exe file).

    If I do away with the splash screen, then the published program starts with its main form having focus, as one would expect.

    Any ideas how I fix this, please?

    Regards
    Allan Stead
  • Robbie
    New Member
    • Mar 2007
    • 180

    #2
    In VB6 there's a function ZOrder(), which is used like this:
    [code=vb]SomeForm.ZOrder (vbBringToFront )[/code]
    That function would probably do what you want to be done.

    I don't know if this exists in the version of VB you're using.
    But you could try searching through its functions or documentation for a way to bring it back to the top (since it might be named similarly to this...?)

    Comment

    • Allan Stead
      New Member
      • Jul 2007
      • 7

      #3
      Hi Robbie

      Thanks for the suggestion. In VB Express the command appears to be Me.BringToFront () and I entered it at the end of the FormActivated event of my main program form, but it didn't solve the problem.

      Thanks for trying, anyway

      Allan

      Comment

      • Killer42
        Recognized Expert Expert
        • Oct 2006
        • 8429

        #4
        Originally posted by Allan Stead
        ... Me.BringToFront () ... end of the FormActivated event ... didn't solve the problem.
        Try doing it immediately after the command which hides (or unloads) the splash form.

        Also, though I don't know what your equivalent would be, in VB6 SomeForm.Show would work just as well, and would confuse less people. :) Admittedly though, the BringToFront() method sounds rather more obvious than ZOrder.

        Comment

        • Allan Stead
          New Member
          • Jul 2007
          • 7

          #5
          Originally posted by Killer42
          Try doing it immediately after the command which hides (or unloads) the splash form.

          Also, though I don't know what your equivalent would be, in VB6 SomeForm.Show would work just as well, and would confuse less people. :) Admittedly though, the BringToFront() method sounds rather more obvious than ZOrder.
          I'm not sure if I'll be able to take up this suggestion, as VB Express shows and hides the splash screen all by itself as an option from within the Application tab of My Project. Any idea how I can get at the hide or unload command?

          Comment

          • Robbie
            New Member
            • Mar 2007
            • 180

            #6
            Originally posted by Allan Stead
            Any idea how I can get at the hide or unload command?
            No, but if VB Express is failing to give focus back, then it isn't working as it should.

            Why don't you make your own one?
            It's really very simple... if it's only meant to be an image:
            Make a new form called SplashForm or something like that,
            Add a PictureBox which shows the splash image,
            Set the form properties so that no border is shown,
            Add a timer which, after a certain amount of time, hides this form, and shows the main program form and tries to bring focus to it (using example code which Killer / I have suggested).

            I would at least try that before giving up. ^-'

            Comment

            • waynespangler
              New Member
              • Sep 2006
              • 8

              #7
              Here is some code to try:

              Code:
              	Dim Done As Boolean = False
              	Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
              		Me.Visible = False
              		SplashScreen1.Show(Me)
              		Do While Not Done
              			My.Application.DoEvents()
              		Loop
              		SplashScreen1.Close()
              		Me.Visible = True
              	End Sub
              	Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
              		Done = True
              	End Sub

              Comment

              • Killer42
                Recognized Expert Expert
                • Oct 2006
                • 8429

                #8
                Originally posted by Allan Stead
                I'm not sure if I'll be able to take up this suggestion, as VB Express shows and hides the splash screen all by itself as an option from within the Application tab of My Project. Any idea how I can get at the hide or unload command?
                I'm not familiar with this version. But I have heard mention of an option which hides "cookie-cutter" code, showing only your own. Perhaps you just need to turn off that option to see the code supplied by VB Express.

                Comment

                • Budman
                  New Member
                  • Sep 2007
                  • 1

                  #9
                  That worked great—very nice! I was pulling out what is left of my hair trying to get the focus back to the application after the splash screen went away. Using the Project Designer to specify a Splash Screen form does not cut it. Thanks loads.

                  Comment

                  Working...