Application 类
Application 类具有用于启动和停止应用程序和线程以及处理 Windows 消息的方法,如下所示:
Run 在当前线程上启动应用程序消息循环,并可以选择使某窗体可见。
Exit 或 ExitThread 停止消息循环。
DoEvents 在您的程序处于某个循环中时处理消息。
AddMessageFilter 向应用程序消息泵添加消息筛选器来监视 Windows 消息。
IMessageFilter 使您可以阻止引发某事件或在调用某事件处理程序前执行特殊操作。
该类具有用于获取或设置当前线程的区域性信息的 CurrentCulture 和 CurrentInputLanguage 属性。
不能创建此类的实例。
Application.EnableVisualStyles();//Enables visual styles for the application
Application.SetCompatibleTextRenderingDefault(false);//If true, new controls that support UseCompatibleTextRendering use
//the GDI+ based Graphics class for text rendering;
//if false, new controls use the GDI based TextRenderer class;In Visual C# 2005 or later,
//a call to SetCompatibleTextRenderingDefault is automatically generated in the Program.cs file.
Application.Run(new mainFrm());
示例代码:
public class Form1 : Form
{
[STAThread]
public static void Main()
{
// Start the application.
Application.Run(new Form1());
} private Button button1;
private ListBox listBox1; public Form1()
{
button1 = new Button();
button1.Left = ;
button1.Text = "Exit";
button1.Click += new EventHandler(button1_Click); listBox1 = new ListBox();
this.Controls.Add(button1);
this.Controls.Add(listBox1);
} private void button1_Click(object sender, System.EventArgs e)
{
int count = ;
// Check to see whether the user wants to exit the application.
// If not, add a number to the list box.
while (MessageBox.Show("Exit application?", "",
MessageBoxButtons.YesNo)==DialogResult.No)
{
listBox1.Items.Add(count);
count += ;
} // The user wants to exit the application.
// Close everything down.
Application.Exit();
}
}
Application 类的更多相关文章
- Android Application类作用简单说明
每个程序运行时创建一个Application类的对象且只创建一个 Application对象的生命周期是整个程序中最长的,它的生命周期就等于这个程序的生命周期. Application来进行一些,如: ...
- [转]Android中Application类的用法
原文链接:http://www.cnblogs.com/renqingping/archive/2012/10/24/Application.html Application类 Application ...
- 【转】Android中Application类用法
转自:http://www.cnblogs.com/renqingping/archive/2012/10/24/Application.html Application类 Application和A ...
- WPF的Application类
本节主要介绍一下Application类的部分功能,我们首先来看一下如何使用Application类来加载一个窗口: 我们首先创建一个控制台程序,并引入相关的dll,然后修改Main()方法. [ST ...
- android application类的用法
android application类的用法 Application是android系统Framework提供的一个组件,它是单例模式(singleton),即每个应用只有一个实例,用来存储系统的一 ...
- Android(java)学习笔记120:Android中的Application类用法
1.简介 如果想在整个应用中使用全局变量,在java中一般是使用静态变量,public类型:而在android中如果使用这样的全局变量就不符合Android的框架架构,但是可以使用一种更优雅的方式就是 ...
- 六,WPF的Application类
Application.ShutdownMode属性:通过,只要有一个窗口还没有关闭,Application类就保持应用程序处于有效状态,如果这不是所期望的行为,就可以调整该属性. 应用程序事件 Ap ...
- android开发之重写Application类
在android应用开发中,重写Application也算是比较常见的,以前开发的一些程序太过于简单,都不要重写这个类,但是在真正的商业开发中,重写Application类几乎是必做的. 为什么要重写 ...
- Android中用Application类实现全局变量
最近在项目中,遇到了application这个类,开始不知道有什么用,经过学习后才知道它的用途也蛮大的,举个例子,如果想在整个应用中使用全局变量,在java中一般是使用静态变量,public类型:而在 ...
- Android学习笔记(三)Application类简介
每次运行APP时,Application类都保持实例化状态.与Activity不同,配置改变不会导致应用程序重启.通过继承Application类,可以完成一下3项工作: · 对Android运行时广 ...
随机推荐
- Python3: Windows系统上同时安装Python2和Python3
Python3: Windows系统上同时安装Python2和Python3 为什么要同时安装Python2和Python3环境呢? 因为一些库只支持Python2或者Python3; 在同一台电脑上 ...
- mysql服务器,大量tcp连接状态TIME_WAIT
今天早上,java应用中发现too many open files,检查了下使用的连接数发现基本上在两三百左右,mysql打开的文件数也就几百左右,再看所有tcp连接,发现3306的连接有4000多, ...
- 20145337《网络对抗技术》逆向及BOF基础
20145337<网络对抗技术>逆向及BOF基础 实践目标 操作可执行文件pwn1,通过学习两种方法,使main函数直接执行getshall,越过foo函数. 实践内容 手工修改可执行文件 ...
- Duilib应用修改程序图标方法(转载)
转载:http://www.cnblogs.com/lanzhi/p/6468596.html 本文向大家介绍如何修改duilib应用图标,对于win32或者mfc应用来说,我们可以在注册窗口类时指定 ...
- shell脚本中如何使scp不输入密码即可传输文件
答:使用ssh密钥对 示例如下: 如果A机想要获取B机上的文件,那么需要将在A机上生成的公钥放置到B机上的指定位置~/.ssh/authorized_keys 问题一: 如何在A机上生成ssh密钥对? ...
- sql server文件另存为的时候,选择文件编码和换行
文件编码 使用code page来标记的,没有找到utf8 without bom 换行
- neuroph Perceptron Sample
错误: Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory ...
- thymeleaf和easyui配合可能出现的错误
thymeleaf和easyui 在easyui的内页,不再使用th:href引入静态资源文件. 在easyui页面中,script执行easyui自己的方法要加入: <script th:in ...
- jQuery object and DOM Element
They're both objects but DOMElements are special objects. jQuery just wraps DOMElements in a Javascr ...
- CSAPP学习笔记 第一章 计算机系统漫游
Ch 1.0 1.计算机系统是由硬件和系统软件组成的 2.本书阐述了计算机组件是如何工作的以及执行组件是如何影响程序正确性和性能的. 3.通过跟踪hello程序的生命周期来开始对系统的学习. #inc ...