I've got a "Loading" form which I display as a modal form when doing lengthy processes. I'm using the below to keep the form centred within the child form performing the process. However, when minimising\maximising the "Loading" form appears before the parent making it look a little unprofessional.
Anything I can do about that (Delay it appearing or attaching it in a different way)?
Private _childForm As FormBusy
Private Const NIM开发者_开发知识库_DELETE = &H2
Private Sub SetChildFormPosition()
If _childForm Is Nothing Then
Return
End If
Dim newLocation As New Point()
newLocation.X = Me.Location.X + ((Me.Width - _childForm.Width) \ 2)
newLocation.Y = Me.Location.Y + ((Me.Height - _childForm.Height) \ 2)
_childForm.Location = newLocation
End Sub
Private Sub ParentForm_LocationChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.LocationChanged
SetChildFormPosition()
End Sub
When I tried this with empty forms, the two forms appeared at once. It's possible that the delay is in processing Windows messages. You might try putting Application.DoEvents()
inside the loop in the parent form to process messages faster.
精彩评论