Good morning friends of the Group,
I apologize for repeating myself, but I have been facing a recurring problem in a system, when closing a window it returns an error that the window does not exist, but the fact is that it does exist, it was being used until the button that executes a routine that culminates in its closing was pressed, I will explain the context, the detail is that it may be a little long, I appreciate everyone's patience.
There is a window named “janelavendas”, created in this way:
"IF .NOT. ISWINDOWDEFINED(janelavendas)"
The system checks if the window already exists and performs the procedures to create the window with its controls, LABEL, TEXTBOX, BUTTONS, among the controls there is a BTNTEXTBOX that receives the code or the barcode of the product sold or clicks on the BTN and activates a search window, like this:
"@ w_linha,w_coluna BTNTEXTBOX txproduto OF janelavendas HEIGHT 30 WIDTH w_larguraproduto ACTION {||wn_buscaproduto(),IIF(ISWINDOWDEFINED(janelavendas),janelavendas.txproduto.SETFOCUS,.T.)} PICTURE 'BMPBUSCA' BUTTONWIDTH 28 FONT FONTEPADRAO SIZE 18 FONTCOLOR CORFONTEDIGITA DIGITOMAXIMO 35 UPPERCASE ON ENTER {||wn_pesquisaproduto()}"
The BTN triggers the FUNCTION “wn_buscaproduto()”
And the function “wn_buscaproduto” also checks if it exists, if it doesn't exist it is created with its controls, which consists of a BROWSE where it lists the products so that one can be chosen, the creation of the product search window:
"IF ISWINDOWDEFINED(janelabuscaprodutos)
MINIMIZE WINDOW janelabuscaprodutos
RESTORE WINDOW janelabuscaprodutos
ELSE
DBSELECTAREA('sgc_est')
sgc_est->(DBSETORDER(2))
DEFINE WINDOW janelabuscaprodutos AT 00,00 WIDTH (LJANELA-150) HEIGHT 550 TITLE "Product Search" ICON "ICONEAA" CHILD NOSIZE NOSYSMENU"
Please verify that if the window already exists, meaning the user somehow clicked on BTNTEXTBOX, the system minimizes and restores the window. I tried simply setting the focus to: "janelabuscaprodutos.SETFOCUS" but it didn't work.
Within this window, there is a BROWSE where the user locates and selects the product. Clicking the "Select" button calls the function described below, named "WN_SELECIONAPRODUTOS":
"STATIC FUNCTION wn_selecionaprodutos
// Function: Select the product -----------------------------------------.
// Checks if the window exists
IF ISWINDOWDEFINED(janelabuscaprodutos)
sgc_est->(DBGOTO(janelabuscaprodutos.browsebuscaprodutos.VALUE))
// Checks if the previous sales window, where the product goes, exists
IF ISWINDOWDEFINED(janelavendas)
// Updates the controls with the necessary data
janelavendas.txproduto.VALUE := sgc_est->cod_bar
janelavendas.lbproduto.VALUE := sgc_est->des_pro
janelavendas.txunidade.VALUE := sgc_est->unit
IF janelavendas .txquantidade.VALUE <= 0
janelavendas.txquantidade.VALUE := 1.000
ENDIF
janelavendas.txquantidade.SETFOCUS
ENDIF
// Here it checks if the Product Search window still exists
// If the window still exists, it enters the IF to perform the RELEASE
IF ISWINDOWDEFINED(janelabuscaprodutos )
// Here the error occurs, it finds the window, but when it tries to perform the RELEASE, the message is that the window “ janelabuscaprodutos ” no longer exists and the error occurs.
janelabuscaprodutos.RELEASE
ENDIF
ENDIF
DO EVENTS
RETURN(NIL)"
// End of the product selection function ------------------------------------.
The error doesn't occur every time this search function is executed; it happens intermittently.
I hope I've been more assertive in my explanation this time.
I'm using Google Translate to translate from Brazilian Portuguese to English.
Thank you.
Happy New Year to all the friends in the group, and may we all be together in 2026,
Valteçom
Uberaba MG Brazil
Not sure about this:
IF ! IsWindowDefined( janelavendas )
What is it ?
Iswindowsdefined is the same as window is active ?
Is possible that sometimes window is active and sometimes not? but allways defined?
José M. C. Quintas
--
Visit our website on https://www.hmgextended.com/ or https://www.hmgextended.org/
---
You received this message because you are subscribed to the Google Groups "Harbour Minigui" group.
To unsubscribe from this group and stop receiving emails from it, send an email to minigui-foru...@googlegroups.com.
To view this discussion, visit https://groups.google.com/d/msgid/minigui-forum/62ed696a-61b8-4ecc-8f75-a3fe940da7ffn%40googlegroups.com.
To view this discussion, visit https://groups.google.com/d/msgid/minigui-forum/693de44a-818a-47f7-b0b6-a9d7fb9c8f35%40gmail.com.