OnKillFocus running for textboxes on tab control, right after form show

Started by jmaeding, March 23, 2010, 03:28:58 PM

Previous topic - Next topic

jmaeding

I have a modal form with a tab control that has 6 tabs.
Each tab has several textboxes.  I typically have textboxes run the OnKillFocus and OnReturnPressed events to trigger that the user is done with that textbox, and I noticed the OnKillFocus function runs immediately after the form show, even before the initialize event code.  Isn't the initialize the very very first event that can run after a form show?
In addition, the tab control runs its OnChanged event before initialize also.
I am pretty sure this is not proper behavior for 6.0...23, as it worked on version 4.1.
Its having a pretty major effect on things so I want to check.
thanks

jmaeding

feel free to move this to runtime issues, I should have put it there

jmaeding

no replies, guess I better do an example project to demonstrate.
Funny thing is, last time I did this, the issue turned out to be something I solved by removing the varname from my flexgrid control in the editor.  The name was the same as the auto-assigned one, but the varname seemed to prevent the runtime for updating the flexgrid props.  I'm almost thinking you should just get rid of the varname altogether and force us to update code :)
I'll post back in a bit with exmaple....

owenwengerd

There is no law that says OnInitialize must be the first event, but if it's not the first event, there should be a good reason at least. In this case, I'd say there is no good reason. However I'd like to see your sample.
Owen Wengerd (Outside The Box) / ManuSoft

Fred Tomke

jmaeding,

Note that Tab_OnSelChanged event will be fired at creation time. That means it is before OnInitialize.
Note that Textbox_OnKillFocus will be fired on creation tim if it is the first control in the Z/Tab order list. As far as I remember it is valid also for each tab!

That are two samples of event which are fired before OnInitialize.

Fred
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

jmaeding

wow, I believe that is exactly what I am seeing.
I did not run into this before, but maybe because I had buttons at top of z order (by accident).
I cleeaned up the z order when doing the transition to ver 6, and saw issues.
I guess I have to put state checking code in my textbox validation functions.
thx

jmaeding

I'm thinking it is a bad thing for controls to fire events before OnInitialize of form they are owned by.
When is that ever useful?
It is bad because it wastes time firing the callbacks which are looking at default values for the controls.
The default values are never what you want, so it causes confusion in the program for nothing.
What I have to do now is set a global var before calling form_show, then use that flag in my OnKillFocus callbacks to not validate the control.
Is there some way to prevent the events from firing before form starts initializing?

jmaeding

now that i am using flags to avoid callbacks running before form initializes, are there other events besides onkillfocus, and the OnChanged for tabs?
Is there any way for me to investigate other than a test project with every event in the world set to run?