Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Questions (Windows Mobile)
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Questions (Windows Mobile) Post any question regarding Basic4ppc.

SIPChanged fired in a wrong place

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-26-2009, 08:50 PM
ghale's Avatar
Basic4ppc Veteran
 
Join Date: Dec 2008
Location: Earth, Europe, Italy, Puglia, Lecce
Posts: 219
Question SIPChanged fired in a wrong place

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!

Is this normal???

Last edited by ghale : 07-26-2009 at 09:04 PM.
Reply With Quote
  #2 (permalink)  
Old 07-29-2009, 02:40 PM
ghale's Avatar
Basic4ppc Veteran
 
Join Date: Dec 2008
Location: Earth, Europe, Italy, Puglia, Lecce
Posts: 219
Default

I'm managing this issue with exceptions.
But I'm the only one that have this issue?
Reply With Quote
  #3 (permalink)  
Old 07-29-2009, 04:05 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

When an any event occurs all event Subs associated with that event run regardless of the module they are defined in.
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
Reply With Quote
  #4 (permalink)  
Old 07-29-2009, 04:17 PM
ghale's Avatar
Basic4ppc Veteran
 
Join Date: Dec 2008
Location: Earth, Europe, Italy, Puglia, Lecce
Posts: 219
Default

Yes, but...
normally in a form if a click on a button, this will fire an event, but only focused on the button I press.

Why here if I open the SIP in a form, the events that is contained in another form with another object associated is fired?
Reply With Quote
  #5 (permalink)  
Old 07-29-2009, 04:38 PM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Fully, Switzerland
Posts: 4,463
Awards Showcase
Forum Contributer Beta Tester Competition Winner 
Total Awards: 3
Default

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.

Attached a small test program.

Best regards.
__________________
Klaus
Switzerland

Beginner's Guide / User's Guide
Reply With Quote
  #6 (permalink)  
Old 07-29-2009, 04:42 PM
ghale's Avatar
Basic4ppc Veteran
 
Join Date: Dec 2008
Location: Earth, Europe, Italy, Puglia, Lecce
Posts: 219
Default

Very good, Klaus, thanks to you all other people on the forum!
Reply With Quote
  #7 (permalink)  
Old 07-29-2009, 04:48 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Quote:
Originally Posted by ghale View Post
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.
Reply With Quote
  #8 (permalink)  
Old 07-29-2009, 05:01 PM
ghale's Avatar
Basic4ppc Veteran
 
Join Date: Dec 2008
Location: Earth, Europe, Italy, Puglia, Lecce
Posts: 219
Default

Quote:
Originally Posted by agraham View Post
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.
Ok, thanks agraham, repetita iuvant!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Screen size somehow looks wrong enonod Questions (Windows Mobile) 4 07-21-2009 03:05 PM
What is wrong with this SQL? RB Smissaert Questions (Windows Mobile) 1 12-12-2008 02:31 PM
Wrong Notation of Tick value Zenerdiode Questions (Windows Mobile) 4 05-28-2008 04:22 PM
Wrong values on GPS Roadrunner Bug Reports 1 01-31-2008 07:10 PM
Place for dll's BjornF Forum Discussion 5 09-07-2007 10:26 AM


All times are GMT. The time now is 04:41 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0