WindowsFormsApplicationBase WindowsFormsApplicationBase WindowsFormsApplicationBase WindowsFormsApplicationBase Class


Provides properties, methods, and events related to the current application.

public ref class WindowsFormsApplicationBase : Microsoft::VisualBasic::ApplicationServices::ConsoleApplicationBase
public class WindowsFormsApplicationBase : Microsoft.VisualBasic.ApplicationServices.ConsoleApplicationBase
type WindowsFormsApplicationBase = class
    inherit ConsoleApplicationBase
Public Class WindowsFormsApplicationBase
Inherits ConsoleApplicationBase


This example uses a loop to iterate through the application's open forms, selects the forms that can be accessed directly by the current thread, and displays their titles in a ListBox control. For information about how to access the open forms, see OpenForms.

Private Sub GetOpenFormTitles()
    Dim formTitles As New Collection

        For Each f As Form In My.Application.OpenForms
            If Not f.InvokeRequired Then
                ' Can access the form directly.
            End If
    Catch ex As Exception
        formTitles.Add("Error: " & ex.Message)
    End Try

    Form1.ListBox1.DataSource = formTitles
End Sub

This example requires that your Windows Forms application have a form named Form1 that contains a list box named ListBox1.


The properties exposed by the My.Application object return data that is associated only with the current application or DLL. No system-level information can be altered with My.Application.

The My.Application object consists of the following classes:


WindowsFormsApplicationBase() WindowsFormsApplicationBase() WindowsFormsApplicationBase() WindowsFormsApplicationBase()

Initializes a new instance of the WindowsFormsApplicationBase class.

WindowsFormsApplicationBase(AuthenticationMode) WindowsFormsApplicationBase(AuthenticationMode) WindowsFormsApplicationBase(AuthenticationMode) WindowsFormsApplicationBase(AuthenticationMode)

Initializes a new instance of the WindowsFormsApplicationBase class with the specified authentication mode.


ApplicationContext ApplicationContext ApplicationContext ApplicationContext

Gets the ApplicationContext object for the current thread of a Windows Forms application.

CommandLineArgs CommandLineArgs CommandLineArgs CommandLineArgs

Gets a collection containing the command-line arguments as strings for the current application.

(Inherited from ConsoleApplicationBase)
Culture Culture Culture Culture

Gets the culture that the current thread uses for string manipulation and string formatting.

(Inherited from ApplicationBase)
Deployment Deployment Deployment Deployment

Gets the current application's ClickOnce deployment object, which provides support for updating the current deployment programmatically and support for the on-demand download of files.

(Inherited from ConsoleApplicationBase)
EnableVisualStyles EnableVisualStyles EnableVisualStyles EnableVisualStyles

Determines whether this application will use the Windows XP styles for windows, controls, and so on.

Info Info Info Info

Gets an object that provides properties for getting information about the application's assembly, such as the version number, description, and so on.

(Inherited from ApplicationBase)
InternalCommandLine InternalCommandLine InternalCommandLine InternalCommandLine

Sets the values to use as the current application's command-line arguments.

(Inherited from ConsoleApplicationBase)
IsNetworkDeployed IsNetworkDeployed IsNetworkDeployed IsNetworkDeployed

Gets a Boolean that represents whether the application was deployed from a network using ClickOnce.

(Inherited from ConsoleApplicationBase)
IsSingleInstance IsSingleInstance IsSingleInstance IsSingleInstance

Gets or sets a value that indicates whether this application is a single-instance application.

Log Log Log Log

Gets an object that provides properties and methods for writing event and exception information to the application's log listeners.

(Inherited from ApplicationBase)
MainForm MainForm MainForm MainForm

Gets or sets the main form for this application.

MinimumSplashScreenDisplayTime MinimumSplashScreenDisplayTime MinimumSplashScreenDisplayTime MinimumSplashScreenDisplayTime

Gets or sets the minimum length of time, in milliseconds, for which the splash screen is displayed.

OpenForms OpenForms OpenForms OpenForms

Gets a collection of all the application's open forms.

SaveMySettingsOnExit SaveMySettingsOnExit SaveMySettingsOnExit SaveMySettingsOnExit

Determines whether the application saves the user settings on exit.

ShutdownStyle ShutdownStyle ShutdownStyle ShutdownStyle

Determines what happens when the application's main form closes.

SplashScreen SplashScreen SplashScreen SplashScreen

Gets or sets the splash screen for this application.

UICulture UICulture UICulture UICulture

Gets the culture that the current thread uses for retrieving culture-specific resources.

(Inherited from ApplicationBase)
UseCompatibleTextRendering UseCompatibleTextRendering UseCompatibleTextRendering UseCompatibleTextRendering

When overridden in a derived class, this property allows a designer to specify the default text rendering engine for the application's forms.


ChangeCulture(String) ChangeCulture(String) ChangeCulture(String) ChangeCulture(String)

Changes the culture used by the current thread for string manipulation and for string formatting.

(Inherited from ApplicationBase)
ChangeUICulture(String) ChangeUICulture(String) ChangeUICulture(String) ChangeUICulture(String)

Changes the culture that the current thread uses for retrieving culture-specific resources.

(Inherited from ApplicationBase)
DoEvents() DoEvents() DoEvents() DoEvents()

Processes all Windows messages currently in the message queue.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetEnvironmentVariable(String) GetEnvironmentVariable(String) GetEnvironmentVariable(String) GetEnvironmentVariable(String)

Returns the value of the specified environment variable.

(Inherited from ApplicationBase)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
HideSplashScreen() HideSplashScreen() HideSplashScreen() HideSplashScreen()

Hides the application's splash screen.

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
OnCreateMainForm() OnCreateMainForm() OnCreateMainForm() OnCreateMainForm()

When overridden in a derived class, allows a designer to emit code that configures the splash screen and main form.

OnCreateSplashScreen() OnCreateSplashScreen() OnCreateSplashScreen() OnCreateSplashScreen()

When overridden in a derived class, allows a designer to emit code that initializes the splash screen.

OnInitialize(ReadOnlyCollection<String>) OnInitialize(ReadOnlyCollection<String>) OnInitialize(ReadOnlyCollection<String>) OnInitialize(ReadOnlyCollection<String>)

Sets the visual styles, text display styles, and current principal for the main application thread (if the application uses Windows authentication), and initializes the splash screen, if defined.

OnRun() OnRun() OnRun() OnRun()

Provides the starting point for when the main application is ready to start running, after the initialization is done.

OnShutdown() OnShutdown() OnShutdown() OnShutdown()

When overridden in a derived class, allows for code to run when the application shuts down.

OnStartup(StartupEventArgs) OnStartup(StartupEventArgs) OnStartup(StartupEventArgs) OnStartup(StartupEventArgs)

When overridden in a derived class, allows for code to run when the application starts.

OnStartupNextInstance(StartupNextInstanceEventArgs) OnStartupNextInstance(StartupNextInstanceEventArgs) OnStartupNextInstance(StartupNextInstanceEventArgs) OnStartupNextInstance(StartupNextInstanceEventArgs)

When overridden in a derived class, allows for code to run when a subsequent instance of a single-instance application starts.

OnUnhandledException(UnhandledExceptionEventArgs) OnUnhandledException(UnhandledExceptionEventArgs) OnUnhandledException(UnhandledExceptionEventArgs) OnUnhandledException(UnhandledExceptionEventArgs)

When overridden in a derived class, allows for code to run when an unhandled exception occurs in the application.

Run(String[]) Run(String[]) Run(String[]) Run(String[])

Sets up and starts the Visual Basic Application model.

ShowSplashScreen() ShowSplashScreen() ShowSplashScreen() ShowSplashScreen()

Determines if the application has a splash screen defined, and if it does, displays it.

ToString() ToString() ToString() ToString()

Returns a string that represents the current object.

(Inherited from Object)


NetworkAvailabilityChanged NetworkAvailabilityChanged NetworkAvailabilityChanged NetworkAvailabilityChanged

Occurs when the network availability changes.

Shutdown Shutdown Shutdown Shutdown

Occurs when the application shuts down.

Startup Startup Startup Startup

Occurs when the application starts.

StartupNextInstance StartupNextInstance StartupNextInstance StartupNextInstance

Occurs when attempting to start a single-instance application and the application is already active.

UnhandledException UnhandledException UnhandledException UnhandledException

Occurs when the application encounters an unhandled exception.

Applies to

See also