473,396 Members | 2,121 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Application Startup event / Splash+Login Screens

Hi

In my app I have a SplashScreen, a login form and a main form. On launching
the app, I'd like to show the SplashScreen while reading config files and
attempting a database connection. I show progress of these tasks on a label
on the SplashScreen form.
Once this is completed ok, the splash screen should close and the login form
should be displayed. A successful login closes that form and shows the main
form.

I've been trying to get this working using the ApplicationEvents class, but
the problem I'm getting is that the SplashScreen does not close and the login
form appears behind the SplashScreen.

What could be going wrong here? Is this because the SplashScreen does not
get closed automatically until the main form has shown?

I was hoping to get it working this way, but will go back to the old Sub
Main method if not :(

thanks

Richard
Apr 26 '07 #1
10 22284
Hi Richard,

Based on my understanding, when you run your application, you'd like to
display a splash screen first and then the login form. A successful login
closes the login form is closed and shows the main form. If I'm off base,
please feel free to let me know.

It seems that you're using VB.NET. In VB.NET, we could enable application
framework and sepecify a splash screen form.

When the application is run, the Startup event handler of application(if
any) is executed first and immediately the splash screen form is shown, not
waiting for the Startup event handler finishes the execution.

After the application's Startup event handler finishes the execution, the
startup form is created and the Load event handler of the startup form is
called(if any). Note that the splash screen form won't be closed until the
Load event handler of the startup form finishes the execution.

If you set the main form as the startup form and show the login form when
the main form is loaded, it makes sense that the splash screen form is not
closed while the login form is opend.

I suggest that you close the splash screen form before you show the login
form in the main form's Load event handler. The following is a sample.

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
' welcome is the name of the splash screen form
CType(My.Application.SplashScreen, welcome).CloseForm()
Dim frm As New logon
If (frm.ShowDialog() = Windows.Forms.DialogResult.Cancel) Then
Application.Exit()
End If
End Sub

Public Class welcome

Delegate Sub DelegateToCloseForm()

' if the welcome form is closed by the main form, it is cross-thread
operation. so we need to use the Invoke method to deal with it.
Public Sub CloseForm()
If (Me.InvokeRequired) Then
Me.Invoke(New DelegateToCloseForm(AddressOf CloseForm))
Else
Me.Close()
End If
End Sub
End Class

Hope this helps.
If you have anything unclear, please feel free to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Apr 26 '07 #2
On Apr 26, 12:24 am, Richard Bysouth <s...@nospam.nospamwrote:
Hi

In my app I have a SplashScreen, a login form and a main form. On launching
the app, I'd like to show the SplashScreen while reading config files and
attempting a database connection. I show progress of these tasks on a label
on the SplashScreen form.
Once this is completed ok, the splash screen should close and the login form
should be displayed. A successful login closes that form and shows the main
form.

I've been trying to get this working using the ApplicationEvents class, but
the problem I'm getting is that the SplashScreen does not close and the login
form appears behind the SplashScreen.

What could be going wrong here? Is this because the SplashScreen does not
get closed automatically until the main form has shown?

I was hoping to get it working this way, but will go back to the old Sub
Main method if not :(

thanks

Richard
I was hoping to get it working this way, but will go back to the old Sub
Main method if not :(
I gave up a long time ago trying to get the startup to work the way I
wanted it to using the "built-in" methods. I ended up using sub main
and launching my Splash in a seperate thread, loading my main form
into memory, registering my user with the database (most of my apps
use windows authentication instead of a login), sending a message to
the Splash screen's thread to close, and finally showing the main
form. It works exactly how I wanted it too, and after writing it the
first time, I can implement it in other projects without much hassle.

Just my two cents.

Thanks,

Seth Rowe

Apr 26 '07 #3
Hi Linda

Thanks for your answer - that pretty much solves the problem for me. It was
just the call to the Close method of the splash screen that I was missing -
had tried this but had come across threading issues.

The only problem that remains is that for some reason the login form appears
behind other applications i.e. does not come to the front. For example, if I
launch my exe from Windows Explorer, the splash screen shows fine, the login
form appears in the taskbar, but the form itself is behind the Explorer
window. Similarly, after a successful login, my main form appears behind
Explorer!

I did read something on this issue somewhere else but can't find it again -
is there something obvious I might be doing wrong?

I didn't get this issue before I introduced the splash screen into my app.

thanks for your help

Richard
Apr 26 '07 #4
Hi Richard,

Thank you for your feedback.

I peformed a test and did see that the login form is displayed behind other
windows. But after a successful login the main form appears on the top of
all other windows.

I think this may be related to the application framework that the VB.NET
application enables. I set the TopMost property of the login form to true
and the problem doesn't exist.

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
CType(My.Application.SplashScreen, welcome).CloseForm()
Dim frm As New logon\
' Set the TopMost property of the login form to true
frm.TopMost = True

If (frm.ShowDialog(Me) = Windows.Forms.DialogResult.Cancel) Then
Application.Exit()
End If
End Sub

Hope this helps.

Sincerely,
Linda Liu
Microsoft Online Community Support

Apr 27 '07 #5
Linda

thanks for your help - that fixes the problem.
Apr 29 '07 #6
Hi Linda

Just discovered a further problem with this. Although the login form appears
to have focus (cursor is in the user id textbox, title bar is active), it
does not actually HAVE the focus! I have to actually click on the form to
activate it.
I have tried many different methods to resolve this but am having no luck.
Have tried:
Me.Focus in the Load/Shown/Activated events
Setting the login form's owner
removing the topmost property.

The strange thing is that if I check the form's Focussed property, this
returns true, even though it does not actually have input focus!

Any ideas?

thanks

Richard
Jun 5 '07 #7
Hi Richard,

I performed a test according to your description, but didn't reproduce the
problem. The logon form gets focused indeed when it appears in my test.

If you don't show the splash screen in your application, i.e. set the
'Splash screen' property to None in the Application tab within the
Properties Designer, does this problem still exist?

If the problem still exists, could you send me a simple project that could
just reproduce the problem? To get my actual email address, remove 'online'
from my displayed email address.

Sincerely,
Linda Liu
Microsoft Online Community Support

Jun 6 '07 #8
Hi Linda

Further to my email reply I think I've solved the problem. I resorted to the
old SendKeys method (something I haven't used since VB6!). I added the
following code to my login form:

Private Sub frmLogin_Shown(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Shown

m_FormLoaded = True
txtUserID.Text = String.Empty

End Sub

Private Sub txtUserID_GotFocus(ByVal sender As Object, ByVal e As
System.EventArgs) Handles txtUserID.GotFocus

'This hack ensures that the user id field receives focus.
'For some reason it appeared to have focus however was not
responding until
'user clicked on the Form!
If m_FormLoaded = False Then
System.Windows.Forms.SendKeys.Send(ControlChars.Ba ck)
txtUserID.Text = String.Empty
End If

End Sub

private m_FormLoaded as boolean

Bit of a hack, but it works!

Richard
Jun 10 '07 #9
Hi Richard,

Thank you for your sample project.

I run it on my machine and did see the problem. I was running my test
application with VS debugger (press F5 to run the application), and the
login form gets focused. However, if I run my test application by
double-clicking it, I see the same problem in my test application.

When I run the application by double-clicking it in Windows Explorer, I
notice that the focus is taken from the Windows Explorer to the splash form
when it is shown. When the splash form is closed from within the
application, the focus is returned back to the Windows Explorer.

I think this problem is caused by the internal implementation of splash
screen.

I have tried your workaround, but unfortunately it doesn't work on my side.

I think a simple workaround of this problem is to cancel the splash screen.
Instead, we could show the splash form as a normal form manually. To do
this, add a module in the application and declare a public splash form in
it. Show the splash form in the application's Startup event handler and
close it in the main form's Load event handler.

Hope this helps.

Sincerely,
Linda Liu
Microsoft Online Community Support

Jun 11 '07 #10
Hi Linda

Thanks for your suggestion. All is working ok at the moment with my
workaround, however I'll certainly bear your solution in mind if I get any
further problems!

Richard
Jun 12 '07 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Steve | last post by:
I am new to .Net and Visual Studio, I have a login form and my main application form. When I login I want to call the application form, and dispose of the login. I have tried doing something...
1
by: _andrea.l | last post by:
In my office I have a lots of application. In every application we have a login and a pw. It is orrible! How to deal the login at all application by a central "thing" that let you to use one...
4
by: Johnnie Miami | last post by:
I'm using VB.Net 2005 beta 2 and have my login form (login.vb) specified as the startup form. If the user is successful logging in, I call my main form (main.vb). This all works fine but the...
2
by: patilj | last post by:
OK, here's the deal. Let's say I got a website called: https://www.blah.com/~account/application/login.php When the user arrives they see a https which is more secure than just http alone....
0
by: Ian Ceicys | last post by:
I’ve been tasked with doing documentation on the project I’ve recently joined. Here’s what I’m looking for in terms of documentation. I want to generate a diagram from a huge .net 1.1...
1
by: Sanjay | last post by:
i wanna develop a splash screen in my windows application using c#.While splash sreen appears at background application componets should gets loaded as soon as component or dependencies gets...
3
by: =?Utf-8?B?RHVrZSAoQU4yNDcp?= | last post by:
The majority of pages on our site need authentication (forms auth against the aspnetdb database). I created an '~/auth' folder with its own config file forcing authentication for any pages in the...
1
by: kokoe25 | last post by:
Hi Guys, I'm using the aspnetdb to control the user access to web application. The case is now change as our customer requirement. they don't want to login/register as a user. Send an email...
1
by: dotnetdev1 | last post by:
Hi Friends, I am new to Coding. And I started my Project recently in which they are following a framework. In that framework Login page was already created and I have to continue...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.