如何制作winform得启动画面

本文介绍了一种使用C#创建启动画面(Splash Screen)的方法,通过继承Form类并自定义图片和文字,实现了应用程序启动时的显示效果。文章详细展示了如何设置窗口位置、边框、背景图片以及在图片上绘制文字。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

None.gifusing System;
None.gif
using System.Collections.Generic;
None.gif
using System.Text;
None.gif
using System.Windows.Forms;
None.gif
using System.Drawing;
None.gif
None.gif
namespace SlashScreenLib
ExpandedBlockStart.gifContractedBlock.gif
dot.gif{
InBlock.gif    
public class SlashScreenForm:Form
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        
static SlashScreenForm slashScreen;
InBlock.gif        Bitmap bitMap;
InBlock.gif        
public static SlashScreenForm SlashScreen
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
get
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
if (slashScreen == null)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    slashScreen 
= new SlashScreenForm();
ExpandedSubBlockEnd.gif                }

InBlock.gif                
return slashScreen;
ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

InBlock.gif 
InBlock.gif        
public SlashScreenForm()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
//SlashScreen肯定显示在屏幕中央
InBlock.gif
            this.StartPosition = FormStartPosition.CenterScreen;
InBlock.gif            
//应该没有边框
InBlock.gif
            this.FormBorderStyle = FormBorderStyle.None;
InBlock.gif            
//获取SlashScreen要显示的图片
InBlock.gif
            bitMap = Resources.Resource.SlashScreen;
InBlock.gif            
//窗口大小与图片大小一致
InBlock.gif
            this.ClientSize = bitMap.Size;
InBlock.gif            
//在图片上写上字
InBlock.gif
            using (Font f = new Font("宋体"18))
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
using (Graphics g = Graphics.FromImage(bitMap))
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    g.DrawString(
"Jillzhang", f, Brushes.Black, 100142);
ExpandedSubBlockEnd.gif                }

ExpandedSubBlockEnd.gif            }

InBlock.gif            
this.BackgroundImage = bitMap;
ExpandedSubBlockEnd.gif        }

InBlock.gif        
protected override void Dispose(bool disposing)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            
base.Dispose(disposing);
InBlock.gif            
if (disposing)
ExpandedSubBlockStart.gifContractedSubBlock.gif            
dot.gif{
InBlock.gif                
if (bitMap != null)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    bitMap.Dispose();
InBlock.gif                    bitMap 
= null;
ExpandedSubBlockEnd.gif                }

ExpandedSubBlockEnd.gif            }

ExpandedSubBlockEnd.gif        }

ExpandedSubBlockEnd.gif    }

ExpandedBlockEnd.gif}

None.gif
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值