WindowsFormsApplicationBase 类

定义

提供与当前应用程序相关的属性、方法和事件。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
继承
WindowsFormsApplicationBase

示例

此示例使用循环来循环访问应用程序的打开的窗体,选择可由当前线程直接访问的窗体,并在控件中显示其标题 ListBoxThis 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. 有关如何访问打开的窗体的信息,请参阅 OpenFormsFor 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

此示例要求 Windows 窗体应用程序具有一个名为的窗体 Form1 ,该窗体包含一个名为的列表框 ListBox1This example requires that your Windows Forms application have a form named Form1 that contains a list box named ListBox1.

注解

对象公开的属性 My.Application 返回仅与当前应用程序或 DLL 关联的数据。The properties exposed by the My.Application object return data that is associated only with the current application or DLL. 无法使用 My.Application 更改任何系统级信息。No system-level information can be altered with My.Application.

My.Application 对象由以下类组成:The My.Application object consists of the following classes:

构造函数

WindowsFormsApplicationBase()

初始化 WindowsFormsApplicationBase 类的新实例。Initializes a new instance of the WindowsFormsApplicationBase class.

WindowsFormsApplicationBase(AuthenticationMode)

使用指定的身份验证模式初始化 WindowsFormsApplicationBase 类的新实例。Initializes a new instance of the WindowsFormsApplicationBase class with the specified authentication mode.

属性

ApplicationContext

获取 Windows 窗体应用程序当前线程的 ApplicationContext 对象。Gets the ApplicationContext object for the current thread of a Windows Forms application.

CommandLineArgs

获取一个集合,该集合包含当前应用程序的字符串形式的命令行参数。Gets a collection containing the command-line arguments as strings for the current application.

(继承自 ConsoleApplicationBase)
Culture

获取当前线程用于字符串操作和字符串格式设置的区域性。Gets the culture that the current thread uses for string manipulation and string formatting.

(继承自 ApplicationBase)
Deployment

获取当前应用程序的 ClickOnce 部署对象,该对象为以编程方式更新当前部署提供支持,并支持文件的即需下载。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.

(继承自 ConsoleApplicationBase)
EnableVisualStyles

确定此应用程序是否将 Windows XP 样式用于窗口、控件等。Determines whether this application will use the Windows XP styles for windows, controls, and so on.

Info

获取一个对象,该对象提供用来获取有关应用程序的程序集的信息(如版本号、说明等等)的属性。Gets an object that provides properties for getting information about the application's assembly, such as the version number, description, and so on.

(继承自 ApplicationBase)
InternalCommandLine

设置要用作当前应用程序的命令行参数的值。Sets the values to use as the current application's command-line arguments.

(继承自 ConsoleApplicationBase)
IsNetworkDeployed

获取一个 Boolean 值,该值表示应用程序是否是使用 ClickOnce 从网络部署的。Gets a Boolean that represents whether the application was deployed from a network using ClickOnce.

(继承自 ConsoleApplicationBase)
IsSingleInstance

获取或设置一个值,该值指示此应用程序是否是单实例应用程序。Gets or sets a value that indicates whether this application is a single-instance application.

Log

获取一个对象,该对象提供用来将事件和异常信息写入应用程序的日志侦听器的属性和方法。Gets an object that provides properties and methods for writing event and exception information to the application's log listeners.

(继承自 ApplicationBase)
MainForm

获取或设置此应用程序的主窗体。Gets or sets the main form for this application.

MinimumSplashScreenDisplayTime

获取或设置显示初始屏幕的最小时间长度(以毫秒为单位)。Gets or sets the minimum length of time, in milliseconds, for which the splash screen is displayed.

OpenForms

获取应用程序中所有打开的窗体的集合。Gets a collection of all the application's open forms.

SaveMySettingsOnExit

确定应用程序在退出时是否保存用户设置。Determines whether the application saves the user settings on exit.

ShutdownStyle

确定应用程序的主窗体关闭时执行的操作。Determines what happens when the application's main form closes.

SplashScreen

获取或设置此应用程序的初始屏幕。Gets or sets the splash screen for this application.

UICulture

获取当前线程用来检索特定于区域性的资源的区域性。Gets the culture that the current thread uses for retrieving culture-specific resources.

(继承自 ApplicationBase)
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)

更改当前线程用于字符串操作和字符串格式设置的区域性。Changes the culture used by the current thread for string manipulation and for string formatting.

(继承自 ApplicationBase)
ChangeUICulture(String)

更改当前线程用来检索特定于区域性的资源的区域性。Changes the culture that the current thread uses for retrieving culture-specific resources.

(继承自 ApplicationBase)
DoEvents()

处理当前在消息队列中的所有 Windows 消息。Processes all Windows messages currently in the message queue.

Equals(Object)

确定指定对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetEnvironmentVariable(String)

返回指定环境变量的值。Returns the value of the specified environment variable.

(继承自 ApplicationBase)
GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
HideSplashScreen()

隐藏应用程序的初始屏幕。Hides the application's splash screen.

MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
OnCreateMainForm()

在派生类中重写后,允许设计器发出配置初始屏幕和主窗体的代码。When overridden in a derived class, allows a designer to emit code that configures the splash screen and main form.

OnCreateSplashScreen()

在派生类中重写后,允许设计器发出初始化初始屏幕的代码。When overridden in a derived class, allows a designer to emit code that initializes the splash screen.

OnInitialize(ReadOnlyCollection<String>)

设置可视样式、文本显示样式以及应用程序主线程的当前主体(如果应用程序使用 Windows 身份验证),如果定义了初始屏幕,还要初始化初始屏幕。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()

在初始化完成后,提供主应用程序准备好开始运行时可运行的起点。Provides the starting point for when the main application is ready to start running, after the initialization is done.

OnShutdown()

在派生类中重写后,允许代码在应用程序关闭时运行。When overridden in a derived class, allows for code to run when the application shuts down.

OnStartup(StartupEventArgs)

在派生类中重写后,允许代码在应用程序启动时运行。When overridden in a derived class, allows for code to run when the application starts.

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)

在派生类中重写后,允许代码在应用程序中出现未经处理的异常时运行。When overridden in a derived class, allows for code to run when an unhandled exception occurs in the application.

Run(String[])

设置或启动 Visual Basic 应用程序模型。Sets up and starts the Visual Basic Application model.

ShowSplashScreen()

确定应用程序是否定义了初始屏幕,如果进行了定义,则显示该初始屏幕。Determines if the application has a splash screen defined, and if it does, displays it.

ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(继承自 Object)

事件

NetworkAvailabilityChanged

在网络可用性更改时发生。Occurs when the network availability changes.

Shutdown

在应用程序关闭时发生。Occurs when the application shuts down.

Startup

在应用程序启动时发生。Occurs when the application starts.

StartupNextInstance

在尝试启动单实例应用程序,而该应用程序已处于活动状态时发生。Occurs when attempting to start a single-instance application and the application is already active.

UnhandledException

在应用程序遇到未经处理的异常时发生。Occurs when the application encounters an unhandled exception.

适用于

另请参阅