Page 1 of 1

Button Enabled attribute

Posted: Thu Apr 04, 2019 3:04 am
by bluebird
Hello Forum

Is there a way to set one of several buttons in a window to be disabled

when its window is first loaded / activated.?

You can set one button Invisible, but how about visible but not active until later logic sets it

enabled:=.T.

Thanks

Re: Button Enabled attribute

Posted: Thu Apr 04, 2019 3:23 am
by Leopoldo Blancas
Hi bluebird,

I do not understand...

Do you want to play with the visible, invisible, enabled and disabled?

Explicate better Please.

regards

Re: Button Enabled attribute

Posted: Thu Apr 04, 2019 3:26 am
by Leopoldo Blancas
I think you have the confusion of the terms, VISIBLE means that you can see the control in the form. VISIBLE: = .T.
  If you do not want to see it then VISIBLE: =. F.
If you want it ACTIVE Enabled: =. T.
Do not remove it active Enabled: =. F.

These two properties are independent of each other, so you can have a button with:
VISIBLE: = .T.
Enabled: =. T.

or another button with:
VISIBLE: = .F.
Enabled: =. T.

Or any combination.

Now with the programming that you want to manage you can change those properties at any time.
 
Enviar comentarios
Historial
Guardadas
Comunidad

Re: Button Enabled attribute

Posted: Thu Apr 04, 2019 8:37 pm
by bluebird
Thanks for your reading my entry - no I am not confused between Enabled and Visible.

With a button you can set VISIBLE .T. or .F. but I did not succeed with Enabled .T. which gave a syntax error.

I want the window hosting the buttons to appear with 3 enabled visible buttons and one visible but not enabled.
It will be enabled later when conditions permit.

Can a button appear disabled when the window is first activated?

Hope this clarifies my problem fellows

Re: Button Enabled attribute

Posted: Thu Apr 04, 2019 9:34 pm
by edk

Code: Select all

#include "hmg.ch"

Function Main()

   DEFINE WINDOW Form_1 ;
      AT 0,0 ;
      WIDTH 200 ;
      HEIGHT 230 ;
      MAIN

      @ 0,70 BUTTON Button_1 CAPTION "door" WIDTH 50 HEIGHT 50 ACTION Nil
	  
      @ 70,70 BUTTON Button_2 CAPTION "window" WIDTH 50 HEIGHT 50 ACTION Nil 

      @ 140,70 BUTTON Button_3 CAPTION "disabled" WIDTH 50 HEIGHT 50 ACTION Nil
      Form_1.Button_3.Enabled := .F.
   
   END WINDOW

   CENTER WINDOW Form_1

   ACTIVATE WINDOW Form_1

Return


Re: Button Enabled attribute

Posted: Fri Apr 05, 2019 1:28 am
by Leopoldo Blancas
Hello edk,

Well, I did not understand what my friend BLEUBIRD wanted, just an observation, if you allow me, it is not advisable to put sentences like
Form_1.Button_3.Enabled: = .F. between DEFINE WINDOWS and END WINDOWS, it is better to put ON INIT in DEFINE WINDOWS and there you put a Function or a Procedures or sentences IF THEY ARE FEW.

It would be something like this:


------------------------------------------------------------------------------------------------------------------------------------------------
Hola edk,

Bien, no entendí lo que quería mi amigo BLEUBIRD, solo una observación, si me lo permites, no es aconsejable poner sentencias como
Form_1.Button_3.Enabled := .F. entre DEFINE WINDOWS y END WINDOWS, es mejor poner ON INIT en DEFINE WINDOWS y ahí pones una Función o un Procedimeinto o sentencias SI SON POCAS.

Quedaria algo así:

Code: Select all

#include "hmg.ch"

Function Main()

   DEFINE WINDOW Form_1 ;
      AT 0,0 ;
      WIDTH 200 ;
      HEIGHT 230 ;
      MAIN;
      ON INIT Form_1.Button_3.Enabled := .F.

      @ 0,70 BUTTON Button_1 CAPTION "door" WIDTH 50 HEIGHT 50 ACTION Nil
	  
      @ 70,70 BUTTON Button_2 CAPTION "window" WIDTH 50 HEIGHT 50 ACTION Nil 

      @ 140,70 BUTTON Button_3 CAPTION "disabled" WIDTH 50 HEIGHT 50 ACTION Nil
   
   END WINDOW

   CENTER WINDOW Form_1

   ACTIVATE WINDOW Form_1

Return
Saludos

Re: Button Enabled attribute

Posted: Fri Apr 05, 2019 6:51 am
by edk
Leopoldo Blancas wrote: Fri Apr 05, 2019 1:28 am Hello edk,

Well, I did not understand what my friend BLEUBIRD wanted, just an observation, if you allow me, it is not advisable to put sentences like
Form_1.Button_3.Enabled: = .F. between DEFINE WINDOWS and END WINDOWS, it is better to put ON INIT in DEFINE WINDOWS and there you put a Function or a Procedures or sentences IF THEY ARE FEW.
Hi Leopoldo Blancas.
I ask with curiosity: not advisable? For what reason?

I always do this when I want to define the initial state of the form and controls and I have never noticed that there are any problems with this.
This must be done in the proper order of defining the form items, of course. ;)

The method you indicate is the most correct, but personally I prefer my own - the code is more readable to me. :)
Edk.

Re: Button Enabled attribute

Posted: Fri Apr 05, 2019 5:27 pm
by Leopoldo Blancas
edk wrote: Fri Apr 05, 2019 6:51 am
Leopoldo Blancas wrote: Fri Apr 05, 2019 1:28 am Hello edk,

Well, I did not understand what my friend BLEUBIRD wanted, just an observation, if you allow me, it is not advisable to put sentences like
Form_1.Button_3.Enabled: = .F. between DEFINE WINDOWS and END WINDOWS, it is better to put ON INIT in DEFINE WINDOWS and there you put a Function or a Procedures or sentences IF THEY ARE FEW.
Hi Leopoldo Blancas.
I ask with curiosity: not advisable? For what reason?

I always do this when I want to define the initial state of the form and controls and I have never noticed that there are any problems with this.
This must be done in the proper order of defining the form items, of course. ;)

The method you indicate is the most correct, but personally I prefer my own - the code is more readable to me. :)
Edk.
Good Friend, everyone has his style of programming !!!

Greetings.