代码语言
.
CSharp
.
JS
Java
Asp.Net
C
MSSQL
PHP
Css
PLSQL
Python
Shell
EBS
ASP
Perl
ObjC
VB.Net
VBS
MYSQL
GO
Delphi
AS
DB2
Domino
Rails
ActionScript
Scala
代码分类
文件
系统
字符串
数据库
网络相关
图形/GUI
多媒体
算法
游戏
Jquery
Extjs
Android
HTML5
菜单
网页交互
WinForm
控件
企业应用
安全与加密
脚本/批处理
开放平台
其它
【
CSharp
】
winform 启动隐藏窗口
作者:
Dezai.CN
/ 发布于
2012/3/1
/
605
<div> <span style="font-size: small;"><span style="font-family: Courier New;"><span class="S5" style="line-height: normal;"><span style="color: rgb(0, 0, 127); line-height: normal;">internal</span></span><span class="S0" style="line-height: normal;"><span style="color: rgb(128, 128, 128); line-height: normal;"><span class="Apple-converted-space"> </span></span></span><span class="S5" style="line-height: normal;"><span style="color: rgb(0, 0, 127); line-height: normal;">class</span></span><span class="S0" style="line-height: normal;"><span style="color: rgb(128, 128, 128); line-height: normal;"><span class="Apple-converted-space"> </span></span></span>HideOnStartupApplicationContext<span class="S0" style="line-height: normal;"><span class="Apple-converted-space"> </span></span><span class="S10" style="line-height: normal;">:</span><span class="S0" style="line-height: normal;"><span style="color: rgb(128, 128, 128); line-height: normal;"><span class="Apple-converted-space"> </span></span></span>ApplicationContext<br style="line-height: normal;" /> <span class="S10" style="line-height: normal;">{</span><br style="line-height: normal;" /> <span class="S5" style="line-height: normal;"><span style="color: rgb(0, 0, 127); line-height: normal;">private</span></span><span class="S0" style="line-height: normal;"><span style="color: rgb(128, 128, 128); line-height: normal;"><span class="Apple-converted-space"> </span></span></span><strong style="color: black; line-height: normal; background-color: rgb(160, 255, 255);">Form</strong><span class="S0" style="line-height: normal;"><span style="color: rgb(128, 128, 128); line-height: normal;"><span class="Apple-converted-space"> </span></span></span>mainFormInternal<span class="S10" style="line-height: normal;">;</span></span></span><span style="line-height: normal; font-size: x-small;"><span style="color: rgb(0, 127, 0); line-height: normal;"><span style="line-height: normal; font-family: 新宋体;"><span class="S2" style="line-height: normal;">// 构造函数,主窗体被存储在mainFormInternal</span><br style="line-height: normal;" /> </span></span></span><span style="line-height: normal; font-family: Courier New;"><span class="S5" style="line-height: normal;"><span style="color: rgb(0, 0, 127); line-height: normal;">public</span></span><span class="S0" style="line-height: normal;"><span style="color: rgb(128, 128, 128); line-height: normal;"><span class="Apple-converted-space"> </span></span></span>HideOnStartupApplicationContext<span class="S10" style="line-height: normal;">(</span><span class="Apple-converted-space"> </span><strong style="color: black; line-height: normal; background-color: rgb(160, 255, 255);">Form</strong><span class="S0" style="line-height: normal;"><span style="color: rgb(128, 128, 128); line-height: normal;"><span class="Apple-converted-space"> </span></span></span>mainForm<span class="S10" style="line-height: normal;">)</span><br style="line-height: normal;" /> <span class="S10" style="line-height: normal;">{</span><br style="line-height: normal;" /> <span class="S5" style="line-height: normal;"><span style="color: rgb(0, 0, 127); line-height: normal;">this</span></span><span class="S10" style="line-height: normal;">.</span>mainFormInternal<span class="S0" style="line-height: normal;"><span style="color: rgb(128, 128, 128); line-height: normal;"><span class="Apple-converted-space"> </span></span></span><span class="S10" style="line-height: normal;">=</span><span class="S0" style="line-height: normal;"><span style="color: rgb(128, 128, 128); line-height: normal;"><span class="Apple-converted-space"> </span></span></span>mainForm<span class="S10" style="line-height: normal;">;</span></span><span style="line-height: normal; font-size: x-small;"><span style="color: rgb(0, 127, 0); line-height: normal;"><span style="line-height: normal; font-family: 新宋体;"><span class="S2" style="line-height: normal;">// 当主窗体被关闭时,退出应用程序</span><br style="line-height: normal;" /> </span></span></span><span style="line-height: normal; font-family: Courier New;"><span class="S5" style="line-height: normal;"><span style="color: rgb(0, 0, 127); line-height: normal;">void</span></span><span class="S0" style="line-height: normal;"><span style="color: rgb(128, 128, 128); line-height: normal;"><span class="Apple-converted-space"> </span></span></span>mainFormInternal_Closed<span class="S10" style="line-height: normal;">(</span><span class="S5" style="line-height: normal;"><span style="color: rgb(0, 0, 127); line-height: normal;">object<span class="Apple-converted-space"> </span></span></span>sender<span class="S10" style="line-height: normal;">,</span><span class="S0" style="line-height: normal;"><span style="color: rgb(128, 128, 128); line-height: normal;"><span class="Apple-converted-space"> </span></span></span>EventArgs<span class="S0" style="line-height: normal;"><span style="color: rgb(128, 128, 128); line-height: normal;"><span class="Apple-converted-space"> </span></span></span>e<span class="S10" style="line-height: normal;"><span class="Apple-converted-space"> </span>)</span><br style="line-height: normal;" /> <span class="S10" style="line-height: normal;">{</span><br style="line-height: normal;" /> Application<span class="S10" style="line-height: normal;">.</span>Exit<span class="S10" style="line-height: normal;">();<span class="Apple-converted-space"> </span></span><br style="line-height: normal;" /> <span class="S10" style="line-height: normal;">}</span><br style="line-height: normal;" /> <span class="S10" style="line-height: normal;">}</span><br style="line-height: normal;" /> </span><span style="line-height: normal; font-size: x-small;"><span style="color: rgb(0, 127, 0); line-height: normal;"><span style="line-height: normal; font-family: 新宋体;"><span class="S2" style="line-height: normal;">//在Main中作如下修改:</span><span class="Apple-converted-space"> </span><br style="line-height: normal;" /> </span></span></span><span style="line-height: normal; font-family: Courier New;">HideOnStartupApplicationContext<span class="S0" style="line-height: normal;"><span style="color: rgb(128, 128, 128); line-height: normal;"><span class="Apple-converted-space"> </span></span></span>context<span class="S0" style="line-height: normal;"><span style="color: rgb(128, 128, 128); line-height: normal;"><span class="Apple-converted-space"> </span></span></span><span class="S10" style="line-height: normal;">=</span><span class="Apple-converted-space"> </span><span class="S5" style="line-height: normal;"><span style="color: rgb(0, 0, 127); line-height: normal;">new</span></span><span class="S0" style="line-height: normal;"><span style="color: rgb(128, 128, 128); line-height: normal;"><span class="Apple-converted-space"> </span></span></span>HideOnStartupApplicationContext<span class="S10" style="line-height: normal;">(</span><span class="Apple-converted-space"> </span><span class="S5" style="line-height: normal;"><span style="color: rgb(0, 0, 127); line-height: normal;">new</span></span><span class="S0" style="line-height: normal;"><span style="color: rgb(128, 128, 128); line-height: normal;"><span class="Apple-converted-space"> </span></span></span>Form1<span class="S10" style="line-height: normal;">());</span><br style="line-height: normal;" /> Application<span class="S10" style="line-height: normal;">.</span>Run<span class="S10" style="line-height: normal;">(</span>context<span class="Apple-converted-space"> </span><span class="S10" style="line-height: normal;">);</span></span><span style="line-height: normal; font-size: x-small;"><span style="color: rgb(0, 127, 0); line-height: normal;"><span style="line-height: normal; font-family: 新宋体;"><span class="S2" style="line-height: normal;">//隐藏窗体的方法5/5: 推荐使用!!!</span><br style="line-height: normal;" /> <span class="S2" style="line-height: normal;">//在构造函数中或者直接设置<strong style="color: black; line-height: normal; background-color: rgb(160, 255, 255);">form</strong>属性</span><br style="line-height: normal;" /> </span></span></span><span style="line-height: normal; font-family: Courier New;"><span class="S5" style="line-height: normal;"><span style="color: rgb(0, 0, 127); line-height: normal;">this</span></span><span class="S10" style="line-height: normal;">.</span>ShowInTaskbar<span class="S0" style="line-height: normal;"><span style="color: rgb(128, 128, 128); line-height: normal;"><span class="Apple-converted-space"> </span></span></span><span class="S10" style="line-height: normal;">=</span><span class="S0" style="line-height: normal;"><span style="color: rgb(128, 128, 128); line-height: normal;"><span class="Apple-converted-space"> </span></span></span><span class="S5" style="line-height: normal;"><span style="color: rgb(0, 0, 127); line-height: normal;">false</span></span><span class="S10" style="line-height: normal;">;</span><br style="line-height: normal;" /> <span class="S5" style="line-height: normal;"><span style="color: rgb(0, 0, 127); line-height: normal;">this</span></span><span class="S10" style="line-height: normal;">.</span>WindowState<span class="S0" style="line-height: normal;"><span style="color: rgb(128, 128, 128); line-height: normal;"><span class="Apple-converted-space"> </span></span></span><span class="S10" style="line-height: normal;">=</span><span class="S0" style="line-height: normal;"><span style="color: rgb(128, 128, 128); line-height: normal;"><span class="Apple-converted-space"> </span></span></span>FormWindowState<span class="S10" style="line-height: normal;">.</span>Minimized<span class="S10" style="line-height: normal;">;</span></span> <div style="line-height: normal; font-size: 14px; visibility: visible !important; filter: none; word-break: break-all; word-wrap: break-word;">程序中配合notifyIcon 控件一起使用,效果很好!</div> </div>
试试其它关键字
启动隐藏窗口
同语言下
.
文件IO 操作类库
.
Check图片类型[JPEG(.jpg 、.jpeg),TIF,GIF,BMP,PNG,P
.
机器名和IP取得(IPV4 IPV6)
.
Tiff转换Bitmap
.
linqHelper
.
MadieHelper.cs
.
RegHelper.cs
.
如果关闭一个窗体后激活另一个窗体的事件或方法
.
创建日志通用类
.
串口辅助开发类
可能有用的
.
C#实现的html内容截取
.
List 切割成几份 工具类
.
SQL查询 多列合并成一行用逗号隔开
.
一行一行读取txt的内容
.
C#动态修改文件夹名称(FSO实现,不移动文件)
.
c# 移动文件或文件夹
.
c#图片添加水印
.
Java PDF转换成图片并输出给前台展示
.
网站后台修改图片尺寸代码
.
处理大图片在缩略图时的展示
Dezai.CN
贡献的其它代码
(
4037
)
.
多线程Socket服务器模块
.
生成随机密码
.
清除浮动样式
.
弹出窗口居中
.
抓取url的函数
.
使用base HTTP验证
.
div模拟iframe嵌入效果
.
通过header转向的方法
.
Session操作类
.
执行sqlite输入插入操作后获得自动编号的ID
Copyright © 2004 - 2024 dezai.cn. All Rights Reserved
站长博客
粤ICP备13059550号-3