以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  求助等待窗口  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=174427)

--  作者:18523982317
--  发布时间:2022/1/14 16:02:00
--  求助等待窗口
http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=73365&skin=0

用起来了,没问题,就是等待时间有点长,如何变短?或者能够根据程序加载数据的进度来自动调节显示时间?


放在全局代码里面的:
Private waitMess As New System.Windows.Forms.Form()
\'等待窗体
Private sFlog As Boolean = True
Private Sub ShowWaitMess()
    Dim waitMesspic As New System.Windows.Forms.PictureBox()
    waitMesspic.Image = System.Drawing.Image.FromFile(ProjectPath & "Images\\loading.gif")  
    waitMesspic.Dock = System.Windows.Forms.DockStyle.Fill
    waitMesspic.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom
    waitMess.Controls.Add(waitMesspic)
    waitMess.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None
    waitMess.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
    waitMess.TransparencyKey = Color.red
    waitMess.OPacity = 0.9
    waitMess.Width = 1280/1.5  \'固定大小
    waitMess.Height = 720/1.5
    \'waitMess.Width = SysInfo.WorkingAreaWidth \'屏幕大小
    \'waitMess.Height = SysInfo.WorkingAreaHeight
    Try
        If Not waitMess.IsDisposed Then
            waitMess.ShowDialog()   
        End If
    Catch Err As System.Threading.ThreadAbortException
        MessageBox.Show(Err.Message)
    End Try
End Sub

Public Sub WaitShow()
    Try
        If sFlog = True Then
            sFlog = False
            Dim upgradeThread As System.Threading.Thread = Nothing
            upgradeThread = New System.Threading.Thread(New System.Threading.ThreadStart(AddressOf ShowWaitMess))
            upgradeThread.Start()
        End If
    Catch Err As System.Threading.ThreadAbortException
        MessageBox.Show(Err.Message)
    End Try
End Sub

Private Delegate Sub CloseFormDelegate()
Public Sub WaitClose()
    If waitMess.InvokeRequired Then
        waitMess.Invoke(New CloseFormDelegate(AddressOf DoCloseJob))
    Else
        DoCloseJob()
    End If
End Sub

private Sub DoCloseJob()
    Try
        If Not waitMess.IsDisposed Then
            sFlog = True
            waitMess.Close()   
        End If
    Catch Err As System.Threading.ThreadAbortException
        MessageBox.Show(Err.Message)
    End Try
End Sub
[此贴子已经被作者于2022/1/14 16:02:46编辑过]

--  作者:18523982317
--  发布时间:2022/1/14 16:44:00
--  
已经找到答案了,打开关闭中间加载的数据太多了。。。