c\#간단 한 시작 화면 만 드 는 방법
시작 화면 은 프로그램 이 구성 요 소 를 불 러 올 때 사용자 가 조금 만 기다 릴 수 있 도록 하 는 알림 상자 입 니 다.좋 은 소프트웨어 는 시작 대기 수요 가 있 을 때 반드시 시작 화면 을 만들어 야 한다.시작 화면 은 사용자 로 하여 금 프로그램 로드 의 느 린 준 비 를 하 게 하고 로 딩 의 진도 와 내용 을 알 게 할 수 있다.본문 은 단지 기록 의 가장 간단 한 구조 일 뿐이다.
VS 2010 은 C\#Windows 창 프로그램 을 만 들 고 메 인 창 을 FormMain 으로 바 꾸 고 SplashScreen 이라는 창 을 만 듭 니 다.프로그램 에 시작 화면 으로 그림 을 불 러 옵 니 다.다음 그림 입 니 다.
그리고 SplashScreen.cs 코드 편집
/// <summary>
///
/// </summary>
public partial class SplashScreen : Form
{
/// <summary>
///
/// </summary>
static SplashScreen instance;
/// <summary>
///
/// </summary>
Bitmap bitmap;
public static SplashScreen Instance
{
get
{
return instance;
}
set
{
instance = value;
}
}
public SplashScreen()
{
InitializeComponent();
//
const string showInfo = " : , ...";
FormBorderStyle = FormBorderStyle.None;
StartPosition = FormStartPosition.CenterScreen;
ShowInTaskbar = false;
bitmap = new Bitmap(Properties.Resources.SplashScreen);
ClientSize = bitmap.Size;
using (Font font = new Font("Consoles", 10))
{
using (Graphics g = Graphics.FromImage(bitmap))
{
g.DrawString(showInfo, font, Brushes.White, 130, 100);
}
}
BackgroundImage = bitmap;
}
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
if (bitmap != null)
{
bitmap.Dispose();
bitmap = null;
}
components.Dispose();
}
base.Dispose(disposing);
}
public static void ShowSplashScreen()
{
instance = new SplashScreen();
instance.Show();
}
}
그리고 메 인 프로그램 이 시 작 될 때 호출 합 니 다.
static class Program
{
/// <summary>
/// 。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
//
SplashScreen.ShowSplashScreen();
// : ,
//
System.Threading.Thread.Sleep(3000);
//
if (SplashScreen.Instance != null)
{
SplashScreen.Instance.BeginInvoke(new MethodInvoker(SplashScreen.Instance.Dispose));
SplashScreen.Instance = null;
}
Application.Run(new FormMain());
}
}
효 과 는 다음 그림 과 같다.본 고 에서 말 한 것 이 여러분 의 C\#프로 그래 밍 에 도움 이 되 기 를 바 랍 니 다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
C#Task를 사용하여 비동기식 작업을 수행하는 방법라인이 완성된 후에 이 라인을 다시 시작할 수 없습니다.반대로 조인(Join)만 결합할 수 있습니다 (프로세스가 현재 라인을 막습니다). 임무는 조합할 수 있는 것이다. 연장을 사용하여 그것들을 한데 연결시키는 것이...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.