I do not expect any object on the form to exist until the form gets to its
INIT method.
According to the order in which events fire, all contained objects
instantiate (ie exist) _before_ the form init.
You can test this by placing code like this in the init methods of the
DE, the form and all contained objects:
DEBUGOUT "label1 init"
DEBUGOUT "form init"
etc
You can also put that code in the load,destroy and unload events of the
form, the valid, keypress,lostfocus, etc of all contained objects.
Just create a test form and put the debugout keyword with a text
indicating what event is firing and run the form.
The debug window will open and you will see in writing how each event is
firing.
You will notice that all contained objects init events fire before the
form's init
BTW, I use a form like this every time things do not happen the way my
logic says they should and oftentimes I am proven wrong.
Rafael Copquin
El 08/11/2012 05:52 p.m., Tracy Pearson escribió:
MB Software Solutions, LLC wrote on 2012-11-08:
I've got a form where some labels should appear in the TOP of the object
hierarchy and hence instantiate before some other objects that depend on
them to have a custom property. Without the proper order, some other
objects encounter an error because the Init of those labels didn't yet
happen to create a custom property on them.
Is this something I have to hack the SCX to achieve? I tried deleting
and re-adding the objects but that didn't help. I'm guessing it has
something to do with the timestamp in the SCX?
tia,
--Mike
Mike,
If your labels are on the form, not in containers you could use the SETALL()
method of the form to call a method in the label. This was VFP 6 days for
me.
If you have containers, this is a good use of BINDEVENTS.
To use BINDEVENTS you need to have 2 methods on the label class.
FormInitEvent
FormInitMethod
Procedure FormInitEvent
THIS.FormInitMethod()
EndProc
Procedure FormInitMethod
** Your code goes here
EndProc
Procedure Init
BINDEVENT(THISFORM, "INIT", THIS, "FORMINITEVENT")
EndProc
If you call the method directly, anticipate strange behavior.
Once in the FormInitMethod procedure you can access objects outside of the
label. Inside the FormInitEvent, it is hit or miss. In my experience, it is
usually a miss in the runtime.
I do not expect any object on the form to exist until the form gets to its
INIT method.
Tracy Pearson
PowerChurch Software
[excessive quoting removed by server]
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox
OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message:
http://leafe.com/archives/byMID/profox/[email protected]
** All postings, unless explicitly stated otherwise, are the opinions of the
author, and do not constitute legal or medical advice. This statement is added
to the messages for those lawyers who are too stupid to see the obvious.