I use a background worker to do some tasks, when the background worker completed successfully a message box appears, the problem I have is if i minimize my form and the message box appears when i click on the form the message boxstill appears to be miminized unless i click on the message box - i can see it in the taskbar at the bottom but its minimized?
Would it be possible for when the user clicks on the form in the taskbar then the message box to appear with the form?
Currently I have tried adding the following before hte message box however the messagebox still appears to be minimized.
me.activate
Update
Sorry for not adding the coding, i thought as it was basic coding it wouldnt matter but here it is....
Private Sub BGWorker_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BGWorker.DoWork
If Not worker.CancellationPending Then
‘ Do code
If worker.CancellationPending Then
e.Cancel = True
‘ Do Code
Exit Sub
End If
End If
End Sub
Private Sub BGWorker_RunWorkerCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles BGWorker.RunWorkerCompleted
Me.Activate()
If e.Cancelled Then
Messagebox.show(“Cancelled”)
Else
Messagebox.show(“Successful”)
End If
End Sub
The problem is if I leave my screen at the top of the other screens then its fine the message box appears however if its minimised ir if i have other windows covering the form then the message box stays minimized unless i click on it in the taskbar.
I thought the me.activate would help me in the sense that the message box would only ever appear within the form.
I made a test project using your code and I was able to reproduce and fix the problem. The Activate
method does not un-minimize the form. To do that, you need to set the WindowState
property. Try this:
Private Sub BGWorker_RunWorkerCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles BGWorker.RunWorkerCompleted
Me.WindowState = FormWindowState.Normal ' Add this line
Me.Activate()
If e.Cancelled Then
Messagebox.show(“Cancelled”)
Else
Messagebox.show(“Successful”)
End If
End Sub
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.