JedNebula
asked on
VB6 ImageList control prevent Terminate Event
I am helping out supporting a VB6 project that has a couple of UserControls. I have been tracking down a memory leak issue.
I've narrowed it down to one of the controls that doesn't unload properly even though it doesn't seem to be referenced elsewhere.
I've replicated the problem in a demo app, and attached it as a zip file. You'll need to rename the .txt files to .ctl before opening the project though. EE won't accept .ctl files yet.
Im summary, with the check box unchecked, the Terminate Event fires when Form2 closes (as I need it to), but when it is checked, it doesn't fire until the app closes down (form1 closes). The behavior seems to be the same both compiled and in the IDE.
I'm hoping you can help.
image-list-dispose-problem.zip
I've narrowed it down to one of the controls that doesn't unload properly even though it doesn't seem to be referenced elsewhere.
I've replicated the problem in a demo app, and attached it as a zip file. You'll need to rename the .txt files to .ctl before opening the project though. EE won't accept .ctl files yet.
Im summary, with the check box unchecked, the Terminate Event fires when Form2 closes (as I need it to), but when it is checked, it doesn't fire until the app closes down (form1 closes). The behavior seems to be the same both compiled and in the IDE.
I'm hoping you can help.
image-list-dispose-problem.zip
I don't know if you consider this an acceptable solution but this resolves the problem.
Private Sub Command1_Click()
Dim x As New Form2
'x.MyProductMenu.bIgnoreSet = (chkInitImageList.Value = vbUnchecked)
x.MyProductMenu.bIgnoreSet = True
x.Show
End Sub
ASKER
Thank you Martin, but I think that just bypasses the test.
I need to pass the object reference to the child control and still have the parent control terminate event fire when it should.
I need to pass the object reference to the child control and still have the parent control terminate event fire when it should.
I added some Debug.Print statements to this project. I don't think I did anything else but the app shows the same results with or without the checkbox being checked.
28962832.zip
28962832.zip
ASKER
Hi Martin,
You code supresses the ImageList being passed to the button so it cannot be used.
I need the control to be passed. I just put the option not to pass it, to demonstrate that this seems to be causing the problem with the Terminate event.
I've attached the project again with example usage of the control. (the
28962832.zip
You code supresses the ImageList being passed to the button so it cannot be used.
I need the control to be passed. I just put the option not to pass it, to demonstrate that this seems to be causing the problem with the Terminate event.
I've attached the project again with example usage of the control. (the
28962832.zip
I've never used it but from what I've read, the Ambient.UserMode property "specifies if the environment is in design mode or end user mode". Why do you care about that and have you tested the app for memory leaks in both the IDE and as an exe?
ASKER
Hi Martin,
Yes as I put in my original question, the behaviour seems the same when compiled as an exe and in the IDE.
You're right about the UserMode property's use. Tbh you could probably strip that part out of the code of you want. I just do it out of habbit because it stops the events firing when you're designing forms and only fires them when the app is running.
Yes as I put in my original question, the behaviour seems the same when compiled as an exe and in the IDE.
You're right about the UserMode property's use. Tbh you could probably strip that part out of the code of you want. I just do it out of habbit because it stops the events firing when you're designing forms and only fires them when the app is running.
In the code for MyProductMenu change
Private Sub UserControl_Terminate()
to
Public Sub UserControl_Terminate()
and in Form2 Form_Unload add
MyProductMenu.UserControl_ Terminate
Private Sub UserControl_Terminate()
to
Public Sub UserControl_Terminate()
and in Form2 Form_Unload add
MyProductMenu.UserControl_
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER