我有一個閃屏,我使用它時,我從一個智能卡裝載數據,因爲它需要大約35秒來獲取數據我的加載屏幕有一個白色的背景色和我設置後將TransparencyKey設置爲白色以使屏幕透明。 和它工作正常,但大約6秒後回顏色變爲黑色 這裏是加載屏幕的代碼:開機畫面變成黑色6秒
partial class LoadingForm : Form
{
int tickcount = 0;
public bool CloseIt = false;
public string Message = "من فضلك إنتظر قليلا ...";
public Point LocationPoint;
public LoadingForm()
{
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.SupportsTransparentBackColor | ControlStyles.DoubleBuffer, true);
InitializeComponent();
SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.SupportsTransparentBackColor | ControlStyles.DoubleBuffer, true);
LocationPoint = new Point();
LocationPoint.X = -300;
LocationPoint.Y = -300;
lblMessage.Text = Message;
}
private void LoadingForm_Load(object sender, EventArgs e)
{
Left = LocationPoint.X;
Top = LocationPoint.Y;
timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
if (Created)
{
if (tickcount++ == 1)
{
LocationPoint.X = Screen.PrimaryScreen.Bounds.Width/2 - 240;
LocationPoint.Y = Screen.PrimaryScreen.Bounds.Height/2 - 140;
lblMessage.Text = Message;
Left = LocationPoint.X;
Top = LocationPoint.Y;
Width = 480;
Height = 185;
}
if (CloseIt)
{
pictureBox1.Image = null;
Close();
Application.ExitThread();
}
}
}
private void LoadingForm_FormClosing(object sender, FormClosingEventArgs e)
{
timer1.Stop();
timer1.Dispose();
}
}
這是創建一個線程在其上運行的形式類:
public class LoadingProgress
{
LoadingForm frm = new LoadingForm();
string Message = "من فضلك إنتظر قليلا ...";
Thread th;
public void StartProgress()
{
th = new Thread(new ThreadStart(ShowForm));
if (frm == null)
frm = new LoadingForm();
frm.Message = Message;
th.Start();
}
public void Set_Message(string msg)
{
Message = msg;
frm.Message = Message;
}
void ShowForm()
{
frm.ShowDialog();
frm.Dispose();
frm = null;
if (th.ThreadState == ThreadState.Running)
th.Abort();
}
public void Stop()
{
frm.CloseIt = true;
}
public void Set_Position(System.Drawing.Point p)
{
frm.LocationPoint = p;
}
}
我刪除了計時器並測試應用程序,但它給出了同樣的問題 –