Hello,
I've noticed that SIPChanged event associated to a form in a module is fired from another module in another form!
In detail:
I have the Main module that has three forms
I have an Editor Module that has one form
In the editor module I've associated an Hardware Object to the form.
If In one of three forms of the main module I open/close the SIP, I've seen that the SIPChange event from the Editor module is fired and it generates NullReferenceException!
The harware object is independant of a module and a form.
When you open the SIP it fires the event, elsewhere the harware_SIPChanged routine is located.
You could declare the hardware object and the harware_SIPChanged routine in the main module.
Then you could add the SytemState library,
add a SystemState object
declare it with
SysState.New1("ActiveApplication")
and with
SysState.CurrentValue
you can find the active form.
Why here if I open the SIP in a form, the events that is contained in another form with another object associated is fired?
Firstly I think you are confusing Form with Module, Forms have nothing to do with this. Event Subs belong to modules and are associated with Controls or Objects. Controls and library Objects belong to modules but are visible globally.
Changing the state of the SIP, wherever it is done, always causes the SIPChanged event which always runs any event Sub associated with it regardless of which module it is defined in.
You normally predefine Event Subs in the module that owns the Control or Object by "Sub Name_Event" and Basic4ppc automatically associates that Sub with the event. However instead, using AddEvent, you can associate any Sub, whatever its name, to an event and the Sub doesn't then have to be in the same module that owns the Control or Object.
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
Firstly I think you are confusing Form with Module, Forms have nothing to do with this.
Well, I've programmed something with Visual Basic and Visual Basic 2005, so, to say that I'm confusing Form with Module, it's too much for me, eheh !
Quote:
Originally Posted by agraham
Event Subs belong to modules and are associated with Controls or Objects. Controls and library Objects belong to modules but are visible globally.
Changing the state of the SIP, wherever it is done, always causes the SIPChanged event which always runs any event Sub associated with it regardless of which module it is defined in.
I just thinked that the SIP_Changed event belongs only to the module where I created the object.
Quote:
Originally Posted by agraham
You normally predefine Event Subs in the module that owns the Control or Object by "Sub Name_Event" and Basic4ppc automatically associates that Sub with the event. However instead, using AddEvent, you can associate any Sub, whatever its name, to an event and the Sub doesn't then have to be in the same module that owns the Control or Object.