UserForm in POS blocks client tab

2

Good afternoon

I'm showing a userform in event DepoisDeGravar in class FichaClientes of POS:

Private Sub FichaClientes_DepoisDeGravar(ByVal Cliente As String)

   Dim f As New UserForm1
    f.CarregaEntidades (Me.DocumentoVenda.Entidade)
    f.Show
   End If
    Exit Sub

erro:
    MsgBox Err.Description

End Sub

But then I can not close the form of the client card.

As I can see it seems to be looping in and out of focus constantly, I can just close the window on the windows taskbar.

GCP version 9.1509.1028 .

Thank you

    
asked by anonymous 03.07.2018 / 16:26

3 answers

4

First, the f.CarregaEntidades (Me.DocumentoVenda.Entidade) line does not make sense.

The problem may be that the userform is being called "Modal"

Place ShowModal = False

And try putting:

DoEvents
Load UserForm1
UserForm1.CarregaEntidades (cliente)
UserForm1.Show vbModeless
    
03.07.2018 / 17:25
2

@Manuel Quelhas answer is fine, it would only add the fact that in the POS the client card is modal and as such its window automatically goes down. To avoid this is to use windows API:

Const HWND_TOPMOST = -1
Const HWND_NOTOPMOST = -2
Const SWP_NOSIZE = &H1
Const SWP_NOMOVE = &H2
Const SWP_NOACTIVATE = &H10
Const SWP_SHOWWINDOW = &H40

Private Declare Sub SetWindowPos Lib "user32" (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long)
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Private Sub FichaClientes_DepoisDeGravar(ByVal Cliente As String)
Dim f As New UserForm1
Dim hWnd As Long

    f.Show
    hWnd = FindWindow("ThunderDFrame", f.Caption)
    SetWindowPos hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE Or SWP_SHOWWINDOW Or SWP_NOMOVE Or SWP_NOSIZE

    Exit Sub

erro:
    MsgBox Err.Description
End Sub
    
03.07.2018 / 18:33
1

I noticed However, the form I'm opening is not modal and portal does not suspend execution of the previous event. In this case, it may not be the most appropriate because I lose the visual reference of the client in question since, as I do not suspect the event, the form of the customer card is cleaned.

I'll try to open the same form with a specific key in the sales editor

Thanks for the help

    
03.07.2018 / 19:03