bizarre VB windowing race condition?
Posted on 2004-04-26
ok, I've run up against an irritating problem that seems to be some kind of bug in VB's windowing code.
I have a form (form1) .Show()ing a modal form (form2) which does some stuff. form1 has a control with a LostFocus() event. This event seems to be fired at a peculiar time. When debugging the code (or when using messageboxes in code to indicate order of execution) the lostfocus event fires when the form2.Show() command is given just before form2 is actually shown. Otherwise it seems to fire just after form2 returns. That's the first bug.
The second problem is that I actually don't know what the hell is going on in that latter case (just executing the code without any debugging measures). But for whatever reason it seems to be behaving illogically.
noupdate = true 'noupdate is a private signalling variable inside form1
form2.Show 1, Me 'modal, Me is owner
set form1.textbox to form2.returnvar 'returnvar is a public variable set by operations on form2
noupdate = false
if noupdate then exit sub
set form1.textbox to "0"
anyone know anything about this or come across similar problems? Other points that might be of interest are that the prog uses functions in a DLL written in C to do some stuff, but none of that happens anywhere near the above code. There are no MDI forms. No windows API code is being used. My DLL doesn't mess about with window procedures or touch the windowing code in any way whatsoever.
I would be especially grateful if anyone can point me to some accurate information about the order of execution of code in these specialised sorts of windowing scenarios in VB.
Thanks in advance.