Invalid Window Handle

Whenever I close the main application form that holds many TIW controls I get EOS 1400 Invalid Window handle.

I am not sure it is the tms components but wanted to find a way to wait for threads associated with a control to terminate (and/or to terminate these threads) before closing the form.

I cannot seem to debug to the point of finding the culprit.

I close the main app form in the main gui thread.

Any pointers would be appreciated.

Maybe you can put breakpoints in the TMS Instrumentation Workshop destructors and step through these to find out in what destructor of what component there is an issue?

I am including MadExcept bug report information if that will help.
It seems to point to TVrTimerThread or at least waiting for it to terminate.
(Sorry about the length I could not find any file attachment link)



Do you use the component TvrTimer?
If so, do you set it to Enabled = false before your app closes?

I do not think we use TvrTimer directly rather I think it may be part of the VrBlotter(to show a moving graph). But I will check again (yes, someone else's code!)

There are a lot of controls used in quite a few forms so I am not sure where to begin to set breakpoints on destructors.
I have tried the TvRTimer destroy method breakpoint but it does not stop there before the problem.

TVrBlotter is not using a timer or thread, so I cannot see that the error you see would be related to TvrBlotter. Are there other controls you are using and if so, did you try to first disable control that could have animation (like a vrScrollText for example) in the form's OnBeforeClose event to see if this affects your issue?

The control that might have a timer is VrScope - this seems to be a part of VrBlotter.There is a property called Interval (set to 7) and there is a frequency (set to 1) - could that be where the timer comes from?
There is no enabled property but there is an active property - should I set that false or will setting the VrBlotter Enabled property false do the same?

Can you try to set vrScope.Active = false in the OnCloseQuery event of the form that holds VrScope?

I did try that setting VrScope.active to false on the onCloseQuery event handler - but no change.

It might be a coincidence but when I single step through the shutdown calls, TVrTrackBar.Notification is called to remove the BitmapList. This BitMapList is never used and is therefore Nil. I did put in a check to not do anything if it is already Nil but this did not change the outcome.

I cannot see anything wrong with TvrTrackBar and its handling of the notification. 

It is normal this notification is called in the form closing (destroy process)
Can you somehow create a sample source project with which we can reproduce this issue here?

Thanks for the support.
I will try first of all to omit various forms in a duplicate test project to see if one of them might be the cause, or a control on the form.

Trouble is when I single step though and into various procedures when exiting from one of them (and it always seems to be a TMS control) then I get the exception of invalid window handle.