Login window vs Main window

F

Flomo Togba Kwele

I have developed a Windows application which is started with a Shared Main
object. The first thing it does is launch a login window. If the user types in
a correct company, username and password, the login window is disposed and the
main application is run (Application.Run(newprg)).

This works nicely as it is. However, for the user to switch companies, he must
exit the application and re-launch.

How can I make the login window work with both the Shared Main and the
application itself? Once the application loads, it displays items specific to
the newly logged-onto company. If I could just make the application re-load
itself after the login screen is launched from the app!

Thanks, Flomo

--
 
L

Linda Liu [MSFT]

Hi Flomo,

Based on my understanding, you'd like to add a 're-login' function in your
application. If I'm off base, please feel free to let me know.
How can I make the login window work with both the Shared Main and the
application itself?

It should not be difficult. Usually we provide a MenuItem or Button for the
user to re-login the application. When the user clicks the 're-login'
MenuItem or Button, the login window appears waiting for the user to input
new company name, user id and password, if necessary.

If the user clicks the 'OK' button after inputing the required information,
the login window is closed and the main form calls a function to refresh
related content in the application; otherwise, the only thing to do is to
close the login window.

The following is a sample. I add a TextBox and two Buttons on the logon
form. I also place a Label and a Button on the main form. I set the
DialogResult property of one Button on the logon form to "OK" and that of
the other Button on the logon form to "Cancel".

Public Class Form1

Shared compname As String

Shared Sub Main()
Dim frm As New logon
If (frm.ShowDialog() = Windows.Forms.DialogResult.OK) Then
compname = frm.CompanyName
Application.Run(New Form1())
End If
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Label1.Text = compname
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim frm As New logon
If (frm.ShowDialog() = Windows.Forms.DialogResult.OK) Then
compname = frm.CompanyName
Reload()
End If
End Sub

Private Sub Reload()
Label1.Text = compname
End Sub
End Class

Public Class logon

Public ReadOnly Property CompanyName() As String
Get
Return Me.TextBox1.Text
End Get
End Property

End Class

Hope this helps.

If you have any question, 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/subscriptions/managednewsgroups/default.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/subscriptions/support/default.aspx.
==================================================

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

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