I think this problem is due to me missing something fundamental, but there you go.
I am writing an ActiveX control to get some practice. I want to create an IP address control for use within VB (this control is present in the common controls dll but not the ocx provided with VB).
In the Initialise event of the UserControl, I create the IP control using CreateWindowEx in the initialise event. I then call SetWindowLong to subclass the UserControl window so that I can deal with notifications from the IP control. This all works fine - when I place my control on a form, the IP address control is created and its fields can be set. The hook works correctly, and everything seems good.
Now the problem: when I place one of these controls on a form in my test project, the initialise event fires. When I delete it from the form, the Terminate event doesn't fire. If I leave the control on the form and run the test project, the Terminate event fires, followed by the Initialise event again. When I stop the test project again, the terminate event fires correctly, followed by the Initialise event again as expected. But if I then delete the control from the form, the terminate event still does not fire.
What's going on? Is this how it should be? Obviously it is causing me problems, since when I delete the control from the form, the final call to SetWindowLong to unhook the UserControl window doesn't fire, which always ends up crashing VB.
All help, advice gratefully recieved.
Jonathan
j.w.george@virginnet.co.uk
Working against: Visual Basic 6, Access 97, Visual Interdev 6, VBScript, Active Server Pages, SQL Server 6.5, Oracle 7
I am writing an ActiveX control to get some practice. I want to create an IP address control for use within VB (this control is present in the common controls dll but not the ocx provided with VB).
In the Initialise event of the UserControl, I create the IP control using CreateWindowEx in the initialise event. I then call SetWindowLong to subclass the UserControl window so that I can deal with notifications from the IP control. This all works fine - when I place my control on a form, the IP address control is created and its fields can be set. The hook works correctly, and everything seems good.
Now the problem: when I place one of these controls on a form in my test project, the initialise event fires. When I delete it from the form, the Terminate event doesn't fire. If I leave the control on the form and run the test project, the Terminate event fires, followed by the Initialise event again. When I stop the test project again, the terminate event fires correctly, followed by the Initialise event again as expected. But if I then delete the control from the form, the terminate event still does not fire.
What's going on? Is this how it should be? Obviously it is causing me problems, since when I delete the control from the form, the final call to SetWindowLong to unhook the UserControl window doesn't fire, which always ends up crashing VB.
All help, advice gratefully recieved.
Jonathan
j.w.george@virginnet.co.uk
Working against: Visual Basic 6, Access 97, Visual Interdev 6, VBScript, Active Server Pages, SQL Server 6.5, Oracle 7