Splash window

M

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
 
C

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
 
C

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
 
M

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,
 
M

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()
 
C

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
 
M

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
 
C

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top