Event "Changed" of TabStrip1

Started by Emiliano · 2014-06-17 08:44 UTC · 7 replies · SMF topic #2151

You know, there are problems with the event "Changed" the TabStrip1?

When I activated this event and loads the form, the following error:

An OpenDCL function argument processing exception has occurred!
Error: NIL value non allowed
Function: dcl-Control-SetEnabled
Argument: 0


It seems that the value of the ItemIndex is null

I use 8.0.0.6
What exact do you mean by "null"? If you mean zero, that is a valid value. Please provide some context.
author=owenwengerd link=topic=2151.msg10757#msg10757 date=1403004634 wrote:
What exact do you mean by "null"? If you mean zero, that is a valid value. Please provide some context.


Null = nil

Scenario 1
- In the project .Odcl I activated the Event "Changed" of TabStrip1.
- In lisp file I have not included any code
- When I load the form does not appear any error

Scenario 2
- In the project .Odcl I activated the Event "Changed" of TabStrip1.
- In lisp file insert the following code:

(defun c:Progetto/FormPrincipale/TabStrip1#OnChanged (ItemIndex /)
  (if (= ItemIndex 0)
    (dcl-Control-SetEnabled Progetto/FormPrincipale/ButtonOpzioni T)
    (dcl-Control-SetEnabled Progetto/FormPrincipale/ButtonOpzioni nil)
  )
)



- When I load the form, the following error appears:
An OpenDCL function argument processing exception has occurred!
Error: NIL value non allowed
Function: dcl-Control-SetEnabled
Argument: 0


Only now I realized that the error appears when opening the form, perhaps because the "c:Progetto/FormPrincipale/TabStrip1#OnChanged" will start before the form is fully loaded.  :-\

What can I do to prevent the "c:Progetto/FormPrincipale/TabStrip1#OnChanged" is launched when loading the form?
I want that it is only launched when the user changes the TabStrip1
There are numerous ways to handle a situation where you want to handle events only after the form is initialized. The three most common are:
1) Check whether the control symbol (in your case Progetto/FormPrincipale/ButtonOpzioni) is already set
2) Set a global variable your Initialize event handler, then check that variable in the subject event handler
3) Leave the event unchecked in the .odcl file, but set the event property at runtime during Initialize
Hi, I know this very well. As Owen said, you have to set a preinit variable to suppress code within the OnTabChanged event.
At the time the form is created at runtime, the current tab is changed and at that time it may be that not all controls are already created.
Thats why you need this variable. When OnInitialize is called all controls are created so you can set this variable to nil.

Regards, Fred
author=owenwengerd link=topic=2151.msg10760#msg10760 date=1403027922 wrote:
There are numerous ways to handle a situation where you want to handle events only after the form is initialized. The three most common are:
1) Check whether the control symbol (in your case Progetto/FormPrincipale/ButtonOpzioni) is already set
2) Set a global variable your Initialize event handler, then check that variable in the subject event handler
3) Leave the event unchecked in the .odcl file, but set the event property at runtime during Initialize


Thanks for the reply.
I solved that method 2, but I'd like to better understand the first suggestion:
How do I to check whether the control symbol (in my case Progetto/FormPrincipale/ButtonOpzioni) is already set ?
author=Fred Tomke link=topic=2151.msg10762#msg10762 date=1403035728 wrote:
Hi, I know this very well. As Owen said, you have to set a preinit variable to suppress code within the OnTabChanged event.
At the time the form is created at runtime, the current tab is changed and at that time it may be that not all controls are already created.
Thats why you need this variable. When OnInitialize is called all controls are created so you can set this variable to nil.

Regards, Fred


thanks for your clarification !
author=Emiliano link=topic=2151.msg10763#msg10763 date=1403074943 wrote:
How do I to check whether the control symbol (in my case Progetto/FormPrincipale/ButtonOpzioni) is already set ?


(if Progetto/FormPrincipale/ButtonOpzioni (do-stuff-with-button-opzioni1))