I have a form with the TopMost = True property that makes it always above everything, I thought that the dialog that it generated would be above it, since it is supposed to inherit the modal of the main form, but it does not, it always mounts back
I use the normal code to call a MessageBox
MessageBox.Show("Recuerda que debes usar el mismo dedo en todos los intentos." & vbCrLf & vbCrLf & "Intenta nuevamente la captura.", "¡ERROR! - Huella Inconsistente", MessageBoxButtons.OK, MessageBoxIcon.Error)
TopMost property
A topmost form is a form that overlaps all the other (non-topmost) forms even if it is not the active or foreground form.
With this property the dialogs are not generated above the form but are always generated behind this
Is there a way to make the dialogues are above the form or a way that the form is above everything but without overshadowing the dialog that he himself generates?
Apparently a thread type process makes truncate everything because it generates some dialogs as if they were in a different form, that is why they are generated behind this form, this happened to me for example when trying to update a label, for that I used the following code
Delegate Sub AddItemCallBack(ByVal Item As String)
Protected Sub UpdateCalidad(ByVal calidad As String)
If Me.LEstadoHuella.InvokeRequired Then
Dim d As New AddItemCallBack(AddressOf UpdateCalidad)
Me.Invoke(d, New Object() {calidad})
Else
LEstadoHuella.Visible = True
LEstadoHuella.Text = calidad
End If
End Sub
Without that I get this error:
Invalid operation through subprocesses: Control was accessed 'LEstadoHuella' from a sub-process different from the one in which it was created. "
This is the method where I call the message, that process is the thread that validates a captured fingerprint:
Protected Sub Process(ByVal Sample As DPFP.Sample)
DibujarMapa(Sample)
Dim caracteristicas As DPFP.FeatureSet = ExtraerCaracteristicas(Sample, DPFP.Processing.DataPurpose.Enrollment)
' Se verifica que la calidad haya sido buena para continuar
If (Not caracteristicas Is Nothing) Then
Try
Enroller.AddFeatures(caracteristicas) 'Se agregan las caracteristicas capturadas al template
Catch ex As Exception
UpdateCalidad("Huella no coincide o es de mala calidad")
MessageBox.Show("Recuerda que debes usar el mismo dedo en todos los intentos." & vbCrLf & vbCrLf & "Intenta nuevamente la captura.", "¡ERROR! - Huella Inconsistente", MessageBoxButtons.OK, MessageBoxIcon.Error)
PictureHuella.Image = Nothing
Enroller.Clear()
StopCapture()
RaiseEvent OnTemplate(Nothing)
StartCapture()
Finally
UpdateStatus()
'Verificamos si se creó el template
Select Case Enroller.TemplateStatus
Case DPFP.Processing.Enrollment.Status.Ready ' Si fue correcto, y se detiene la captura
RaiseEvent OnTemplate(Enroller.Template)
StopCapture()
Case DPFP.Processing.Enrollment.Status.Failed ' Fallo el proceso de captura y se reinicia la captura nuevamente
Enroller.Clear()
StopCapture()
RaiseEvent OnTemplate(Nothing)
StartCapture()
End Select
End Try
End If
End Sub
But the problem I think is that it is generated in a thread, then generated outside the main form and both are loose, how will return the focus to the main form and generate the dialog instead of generating it inheriting the thread ?
I FOUND THE SOLUTION
I did something simple, created an invisible textbox and did the same process to verify that I had already returned the thread to the main form, so when verifying this, I made a method that was responsible for generating a pop-up message, I did it with parameters for can always use it, with any type of dialog you want to send
Code with Solution
Delegate Sub AddMessageCallBack(ByVal Mensaje As String, ByVal Titulo As String, ByVal Opcion As Integer) 'Delegado que será el que llame nuevamente la opción de Mensajes Emergentes
''' <summary>
''' Genera de Manera sincrona el mensaje emergente
''' </summary>
''' <param name="mensaje"></param>
''' <param name="titulo"></param>
''' <param name="tipo"></param>
''' <remarks></remarks>
Protected Sub SendMensaje(ByVal mensaje As String, ByVal titulo As String, ByVal tipo As Integer)
If Me.TXTMensajes.InvokeRequired Then
Dim d As New AddMessageCallBack(AddressOf SendMensaje)
Me.Invoke(d, New Object() {mensaje, titulo, tipo})
Else
Select Case tipo
Case 1 'Error
MessageBox.Show(mensaje, titulo, MessageBoxButtons.OK, MessageBoxIcon.Error)
Case 2 'Exclamation
MessageBox.Show(mensaje, titulo, MessageBoxButtons.OK, MessageBoxIcon.Warning)
Case 3 'Information
MessageBox.Show(mensaje, titulo, MessageBoxButtons.OK, MessageBoxIcon.Information)
End Select
End If
End Sub