Home All Groups Group Topic Archive Search About
Author
12 Apr 2005 6:55 PM
Mike
Hi ,

I use formBorderStyle = "None" for the splash window.
If I will not open if as a Dialog (frmSplash.ShowDialog) then the form
will not be on the front of other windows.
>From another side when I use "ShowDialog" code stay "frozen" for the
time of Splash is opened.

Any idea how to move formBorderStyle = "None" form to the front.
I will use frmSplash.Hide at the end of MainForm_Load procedure

Thanks,
Mike

Author
12 Apr 2005 8:15 PM
Chris
Try setting Form.TopMost to true on your splash screen.  Don't forget to set
it back to false as you hide your form.

Chris

Show quoteHide quote
"Mike" <y1***@yahoo.com> wrote in message
news:1113332107.434796.77380@o13g2000cwo.googlegroups.com...
> Hi ,
>
> I use formBorderStyle = "None" for the splash window.
> If I will not open if as a Dialog (frmSplash.ShowDialog) then the form
> will not be on the front of other windows.
>>From another side when I use "ShowDialog" code stay "frozen" for the
> time of Splash is opened.
>
> Any idea how to move formBorderStyle = "None" form to the front.
> I will use frmSplash.Hide at the end of MainForm_Load procedure
>
> Thanks,
> Mike
>
Author
13 Apr 2005 12:49 PM
Mike
I tried you preposition myself but it did not work.
>From another posting of Crouchie1998 I took idea about using
Application.DoEvents()
and that really helped after I use 3 lines istead of 2:

frm.TopMost = True
frm.Show()
Application.DoEvents()  ' My problem was here - I forgot this line

Thanks,
Author
12 Apr 2005 8:38 PM
Crouchie1998
I answer this question in VB.NET forums more than any other question.

Do this:

1)  Start a new Windows application
2)  Add a new form (Form2) & a module (Module1) to your project
3)  Make Module1 (sub main) your startup
4)  Module code (copy/paste) into Module1:

Module Module1

  Public spl As New Form1
     Dim nThread As New System.Threading.Thread(AddressOf nThreadProc)
       Sub main()
        spl.Show()
            Application.DoEvents()
            nThread.Sleep(5000)
            nThread.Start()
       End Sub

    Sub nThreadProc()
        Application.Run(New Form2)
    End Sub
End Module

5)  Switch to Form1 & add a label (Label1) & set its text property to
'Splash Screen' - just to prove it the splash screen

6)  Switch to Form2 & add a lable (Label1) & set its text property to 'Main
Form' - to prove its the main form

7)  In the form load event of Form2, type:

spl.Close() ' sp1 is the variable I used in the module for the splash
screen.

Note:
-------

In the module is 'nThread.Sleep(5000)'. Change this to whatever value you
wish the splash screen to be shown for (5000 = 5 seconds)

Note2:
------

For those pedantic people like Herfried (Mr MVP (Copy/paster)) 5000 does not
mean 5 seconds exactly because it depends on the system being used. Some
processors run faster than others... and therefore 5000 maybe 5 second on
one machine, but 4990 maybe 5 seconds on a different machine and so on.

I hope this helps

Crouchie1998
BA (HONS) MCP MCSE
Official Microsoft Beta Tester
Author
13 Apr 2005 12:52 PM
Mike
What the reason using you code if you still use  nThread.Sleep(5000)
The same result I can get by ShowDialog

I idea was using splash during init processes - connect to DB, etc

Anyway, part of you code (Application.DoEvents() ) helped me decided
the problem,


try

frm.TopMost = True
frm.Show()
Application.DoEvents() '' line from your answer

,,,,,,,,,,,,

Finally
frm.Hide()
Author
13 Apr 2005 1:44 PM
Crouchie1998
You are the first person in over 2 years & that is over 50 people who have
ever said anything like this. Are you sure you have it correct?

Crouchie1998
BA (HONS) MCP MCSE
Official Microsoft Beta Tester
Author
13 Apr 2005 2:14 PM
Mike
It work for me - the splash window will be closed exactly before main
window will be shown, the part of code I shown previously

when I wrote : "The same result I can get by ShowDialog " - I mean that
the timer can be set inside splash window and do "Me.close" after 5 sec
Author
13 Apr 2005 7:07 PM
Crouchie1998
But if you do it the way you have it then your code only hide the splash
screen & keeps it in memory, whereas, the code I supplied unloads the form
fine.

My code doesn't use a timer because the Thread .Sleep method instead

I supplied the same code to a Microsoft software developer in the got dot
net forum & he was well happy with it too. Anyway, as long as you are happy
with your solution then that's ok to be the odd one out.

Take it easy

Crouchie1998
BA (HONS) MCP MCSE
Official Microsoft Beta Tester
Author
15 Apr 2005 5:29 PM
Mike
if you do not like Hide, use
frm = Nothing and garbage collector do everything for you
btw it will do it anyway because variable is local and defined : Dim
frm as frmSplash

Any decidion has to have any sense but I do not see reason why do you
create additional thread and Sleep it?
If you can please explain this.
Create a new thread or use ShowDialog at my undestanding absolutely the
same - the rest of the code not executing.

I do not claim that the found decidion the best but it do whateven I
need - show the splash for exactly the same amount of time needed for
DB connect, init controls etc.