DISABLE / ENABLE a button on a form
Moderator: Rathinagiri
-
- Posts: 281
- Joined: Sat May 18, 2019 2:11 pm
- DBs Used: Visual FoxPro, FoxPro
- Location: United States of America
DISABLE / ENABLE a button on a form
Hello all,
Can someone with more HMG experience please explain why I cannot DISABLE and later ENABLE a button on a form?
This should be a simple question.
The confusing thing is that similar code works as expected in HMG_Extended.
Google Translation:
¿Puede alguien con más experiencia en HMG explicar por qué no puedo DISABLE y luego ENABLE un botón en un formulario?
Esta debería ser una pregunta simple.
Lo confuso es que un código similar funciona como se esperaba en HMG_Extended.
Thank you. I really appreciate any help.
Can someone with more HMG experience please explain why I cannot DISABLE and later ENABLE a button on a form?
This should be a simple question.
The confusing thing is that similar code works as expected in HMG_Extended.
Google Translation:
¿Puede alguien con más experiencia en HMG explicar por qué no puedo DISABLE y luego ENABLE un botón en un formulario?
Esta debería ser una pregunta simple.
Lo confuso es que un código similar funciona como se esperaba en HMG_Extended.
Thank you. I really appreciate any help.
- Attachments
-
- Enable_Disable.ZIP
- (2.26 KiB) Downloaded 194 times
Re: DISABLE / ENABLE a button on a form
Red2 wrote: ↑Wed Apr 05, 2023 7:53 pm Hello all,
Can someone with more HMG experience please explain why I cannot DISABLE and later ENABLE a button on a form?
This should be a simple question.
The confusing thing is that similar code works as expected in HMG_Extended.
Google Translation:
¿Puede alguien con más experiencia en HMG explicar por qué no puedo DISABLE y luego ENABLE un botón en un formulario?
Esta debería ser una pregunta simple.
Lo confuso es que un código similar funciona como se esperaba en HMG_Extended.
Thank you. I really appreciate any help.
Tu programa funciona bien en HMG...
Si comentas las siguientes líneas, verás que queda "DISABLED"...
*----------------------------------------------------------------------------------------
Your program works fine in HMG...
If you comment out the following lines, you will see that "DISABLED" remains...
*** SetProperty( "Main", "btnRun", "Enabled", .T. ) /* <---- ???? ---- */
*** Main.btnRun.Enabled := .T. /* <---- ???? ---- */
Andrés González López
Desde Guadalajara, Jalisco. México.
Desde Guadalajara, Jalisco. México.
-
- Posts: 281
- Joined: Sat May 18, 2019 2:11 pm
- DBs Used: Visual FoxPro, FoxPro
- Location: United States of America
Re: DISABLE / ENABLE a button on a form
Hi andyglez,
GOOGLE TRANSLATION:
Gracias por su rápida respuesta.
Sí, la eliminación de esas dos líneas hace que el button se disabled, pero solo DESPUÉS de que finalice su procesamiento.
Durante el procesamiento, el botón NO está deshabilitado (cuando en realidad lo necesito).
Necesito el botón deshabilitado DURANTE su procesamiento de ACTION EVENT.
Nota: Está correctamente deshabilitado en HMG Extended.
---------------------------------------------
Thank you for your prompt response.
Yes, removal of those two lines results in the button being disabled but only AFTER the its processing is finished.
During the processing the button is NOT disabled (when actually I need it).
I need the button disabled DURING its ACTION EVENT processing.
Note: It is correctly disabled in HMG Extended.
QUESTION:
Can button deactivation happen during its processing in "Official" HMG?
Thank you!
Red2
GOOGLE TRANSLATION:
Gracias por su rápida respuesta.
Sí, la eliminación de esas dos líneas hace que el button se disabled, pero solo DESPUÉS de que finalice su procesamiento.
Durante el procesamiento, el botón NO está deshabilitado (cuando en realidad lo necesito).
Necesito el botón deshabilitado DURANTE su procesamiento de ACTION EVENT.
Nota: Está correctamente deshabilitado en HMG Extended.
---------------------------------------------
Thank you for your prompt response.
Yes, removal of those two lines results in the button being disabled but only AFTER the its processing is finished.
During the processing the button is NOT disabled (when actually I need it).
I need the button disabled DURING its ACTION EVENT processing.
Note: It is correctly disabled in HMG Extended.
QUESTION:
Can button deactivation happen during its processing in "Official" HMG?
Thank you!
Red2
Re: DISABLE / ENABLE a button on a form
"I need the button disabled DURING its ACTION EVENT processing."
Con el Do - While que tienes y el MSGINFO(), tu botón está DISABLE hasta que termine y oprimas el botón de "Aceptar"
no necesitas los SetProperty()
*-----------------------------------------------------------------------------------------------------------------------------------------------
With the Do - While you have and the MSGINFO(), your button is DISABLE until it finishes and you press the "OK" button
you don't need the SetProperty()
*** SetProperty( "Main", "btnRun", "Enabled", .F. ) /* <---- ???? ---- */
*** Main.btnRun.Enabled := .F. /* <---- ???? ---- */
DO WHILE seconds() < lnEnd
lnIterations +=1
ENDDO
*** SetProperty( "Main", "btnRun", "Enabled", .T. ) /* <---- ???? ---- */
*** Main.btnRun.Enabled := .T. /* <---- ???? ---- */
msgInfo( )
Con el Do - While que tienes y el MSGINFO(), tu botón está DISABLE hasta que termine y oprimas el botón de "Aceptar"
no necesitas los SetProperty()
*-----------------------------------------------------------------------------------------------------------------------------------------------
With the Do - While you have and the MSGINFO(), your button is DISABLE until it finishes and you press the "OK" button
you don't need the SetProperty()
*** SetProperty( "Main", "btnRun", "Enabled", .F. ) /* <---- ???? ---- */
*** Main.btnRun.Enabled := .F. /* <---- ???? ---- */
DO WHILE seconds() < lnEnd
lnIterations +=1
ENDDO
*** SetProperty( "Main", "btnRun", "Enabled", .T. ) /* <---- ???? ---- */
*** Main.btnRun.Enabled := .T. /* <---- ???? ---- */
msgInfo( )
Andrés González López
Desde Guadalajara, Jalisco. México.
Desde Guadalajara, Jalisco. México.
-
- Posts: 281
- Joined: Sat May 18, 2019 2:11 pm
- DBs Used: Visual FoxPro, FoxPro
- Location: United States of America
Re: DISABLE / ENABLE a button on a form
Hi andyglezl,
GOOGLE TRANSLATION:
Gracias por su sugerencia muy amable.
Incluso cuando se elimina MsgInfo(), el botón no deactivate durante el DO WHILE loop.
Además, MsgInfo() viene DESPUÉS del bucle DO WHILE...ENDDO, por lo que no está causando problemas.
¿Qué puedo hacer para DESHABILITAR un botón durante el tiempo que está ejecutando el código en su ACTION Event?
Mi código de ejemplo simple de HMG demuestra el problema, al menos en mi computadora.
¿Esto no es posible en Official HMG o simplemente me estoy perdiendo algo?
-------------------------------------------------
Thank you for your very kind suggestion.
Even when MsgInfo() is removed, the the button does not deactivate during the DO WHILE loop.
Also, the MsgInfo() comes AFTER the DO WHILE...ENDDO loop so it is not causing my issue.
What can I do to DISABLE a Button during the time it is running code in its ACTION Event?
My simple HMG example code demonstrates the problem, at least on my computer.
Is this not possible in Official HMG or am I simply missing something?
Thanks again,
Red2
GOOGLE TRANSLATION:
Gracias por su sugerencia muy amable.
Incluso cuando se elimina MsgInfo(), el botón no deactivate durante el DO WHILE loop.
Además, MsgInfo() viene DESPUÉS del bucle DO WHILE...ENDDO, por lo que no está causando problemas.
¿Qué puedo hacer para DESHABILITAR un botón durante el tiempo que está ejecutando el código en su ACTION Event?
Mi código de ejemplo simple de HMG demuestra el problema, al menos en mi computadora.
¿Esto no es posible en Official HMG o simplemente me estoy perdiendo algo?
-------------------------------------------------
Thank you for your very kind suggestion.
Even when MsgInfo() is removed, the the button does not deactivate during the DO WHILE loop.
Also, the MsgInfo() comes AFTER the DO WHILE...ENDDO loop so it is not causing my issue.
What can I do to DISABLE a Button during the time it is running code in its ACTION Event?
My simple HMG example code demonstrates the problem, at least on my computer.
Is this not possible in Official HMG or am I simply missing something?
Thanks again,
Red2
Re: DISABLE / ENABLE a button on a form

o que no ejecute nada.
Porque así como está, por más que le des "click" no ejecutará nada hasta que termine el Do-While
*------------------------------------------------------------------------------------------------------------------------

Or do not execute anything.
Because as it is, no matter how much you "click" it, it will not execute anything until the Do-While ends
Quizá este post te pueda servir...
*--------------------------------------------
Maybe this post can help you...
viewtopic.php?p=57887#p57887
Andrés González López
Desde Guadalajara, Jalisco. México.
Desde Guadalajara, Jalisco. México.
Re: DISABLE / ENABLE a button on a form
Guys, finally learn that to make your HMG application responsive while executing long-acting loops (DO WHILE, FOR ... NEXT, etc) you must ALWAYS use the DO EVENTS command inside the loop. Note, since each call to DO Events slows down the loop, it's best to execute this command every n-th step in the loop.
Try setting the loop time to 50 seconds without the Do Events command and see that while the loop is running, the program will stop responding, you won't be able to move the main window or close it normally. All you have to do is do Do Events in the loop and the application will start behaving as usual.
That's all there is to this topic.
Try setting the loop time to 50 seconds without the Do Events command and see that while the loop is running, the program will stop responding, you won't be able to move the main window or close it normally. All you have to do is do Do Events in the loop and the application will start behaving as usual.
That's all there is to this topic.
Code: Select all
DO WHILE seconds() < lnEnd
IF lnIterations%10000 = 0
DO Events
ENDIF
lnIterations ++
ENDDO
Last edited by edk on Thu Apr 06, 2023 8:00 am, edited 1 time in total.
- serge_girard
- Posts: 3309
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Re: DISABLE / ENABLE a button on a form
Thanks EDK! Hope this will solve many problems!
Serge
Serge
There's nothing you can do that can't be done...
-
- Posts: 281
- Joined: Sat May 18, 2019 2:11 pm
- DBs Used: Visual FoxPro, FoxPro
- Location: United States of America
Re: DISABLE / ENABLE a button on a form
Thank you EDK,
I really appreciate you kindly sharing your expertise!!!
Your suggestion informs the user with the visual appearance I wanted.
Thanks again,
Spencer
I really appreciate you kindly sharing your expertise!!!
Your suggestion informs the user with the visual appearance I wanted.
Thanks again,
Spencer