WindowsFormsApplicationBase Class

WindowsFormsApplicationBase Class

 

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

Namespace:   Microsoft.VisualBasic.ApplicationServices
Assembly:  Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)

System.Object
  Microsoft.VisualBasic.ApplicationServices.ApplicationBase
    Microsoft.VisualBasic.ApplicationServices.ConsoleApplicationBase
      Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase

[HostProtectionAttribute(SecurityAction.LinkDemand, Resources = HostProtectionResource.ExternalProcessMgmt)]
public class WindowsFormsApplicationBase : ConsoleApplicationBase

NameDescription
System_CAPS_pubmethodWindowsFormsApplicationBase()

Initializes a new instance of the WindowsFormsApplicationBase class.

System_CAPS_pubmethodWindowsFormsApplicationBase(AuthenticationMode)

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

NameDescription
System_CAPS_pubpropertyApplicationContext

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

System_CAPS_pubpropertyCommandLineArgs

Gets a collection containing the command-line arguments as strings for the current application.(Inherited from ConsoleApplicationBase.)

System_CAPS_pubpropertyCulture

Gets the culture that the current thread uses for string manipulation and string formatting.(Inherited from ApplicationBase.)

System_CAPS_pubpropertyDeployment

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.)

System_CAPS_protpropertyEnableVisualStyles

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

System_CAPS_pubpropertyInfo

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.)

System_CAPS_protpropertyInternalCommandLine

Sets the values to use as the current application's command-line arguments.(Inherited from ConsoleApplicationBase.)

System_CAPS_pubpropertyIsNetworkDeployed

Gets a Boolean that represents whether the application was deployed from a network using ClickOnce.(Inherited from ConsoleApplicationBase.)

System_CAPS_protpropertyIsSingleInstance

Determines whether this application is a single-instance application.

System_CAPS_pubpropertyLog

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

System_CAPS_protpropertyMainForm

Gets or sets the main form for this application.

System_CAPS_pubpropertyMinimumSplashScreenDisplayTime

Determines the minimum length of time, in milliseconds, for which the splash screen is displayed.

System_CAPS_pubpropertyOpenForms

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

System_CAPS_pubpropertySaveMySettingsOnExit

Determines whether the application saves the user settings on exit.

System_CAPS_protpropertyShutdownStyle

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

System_CAPS_pubpropertySplashScreen

Gets or sets the splash screen for this application.

System_CAPS_pubpropertyUICulture

Gets the culture that the current thread uses for retrieving culture-specific resources.(Inherited from ApplicationBase.)

System_CAPS_protpropertySystem_CAPS_staticUseCompatibleTextRendering

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

NameDescription
System_CAPS_pubmethodChangeCulture(String)

Changes the culture used by the current thread for string manipulation and for string formatting.(Inherited from ApplicationBase.)

System_CAPS_pubmethodChangeUICulture(String)

Changes the culture that the current thread uses for retrieving culture-specific resources.(Inherited from ApplicationBase.)

System_CAPS_pubmethodDoEvents()

Processes all Windows messages currently in the message queue.

System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodGetEnvironmentVariable(String)

Returns the value of the specified environment variable.(Inherited from ApplicationBase.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_protmethodHideSplashScreen()

Hides the application's splash screen.

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_protmethodOnCreateMainForm()

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

System_CAPS_protmethodOnCreateSplashScreen()

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

System_CAPS_protmethodOnInitialize(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.

System_CAPS_protmethodOnRun()

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

System_CAPS_protmethodOnShutdown()

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

System_CAPS_protmethodOnStartup(StartupEventArgs)

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

System_CAPS_protmethodOnStartupNextInstance(StartupNextInstanceEventArgs)

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

System_CAPS_protmethodOnUnhandledException(UnhandledExceptionEventArgs)

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

System_CAPS_pubmethodRun(String[])

Sets up and starts the Visual Basic Application model.

System_CAPS_protmethodShowSplashScreen()

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

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

NameDescription
System_CAPS_pubeventNetworkAvailabilityChanged

Occurs when the network availability changes.

System_CAPS_pubeventShutdown

Occurs when the application shuts down.

System_CAPS_pubeventStartup

Occurs when the application starts.

System_CAPS_pubeventStartupNextInstance

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

System_CAPS_pubeventUnhandledException

Occurs when the application encounters an unhandled exception.

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:

  • ApplicationBase provides members that are available in all projects.

  • WindowsFormsApplicationBase provides members that are available in Windows Forms applications.

  • ConsoleApplicationBase provides members that are available in console applications.

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

    Try
        For Each f As Form In My.Application.OpenForms
            If Not f.InvokeRequired Then
                ' Can access the form directly.
                formTitles.Add(f.Text)
            End If
        Next
    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.

.NET Framework
Available since 2.0

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show:
© 2016 Microsoft