Re: Err Object Anomaly Bug in VB6+SP5 and How to Reproduce
- From: "Someone" <nobody@xxxxxxx>
- Date: Thu, 13 Oct 2005 13:08:38 -0400
> The program instability is likely caused by not unhooking your WindowProc
> properly on application shutdown. (Won't happen if you just let the
> application crash!)
In the sample I am not doing it because VB6 will never reach the line that
UnSubClass it. In my real App, I am doing it. I wanted to keep the sample as
small as possible.
> Public gfForm1 as Form1
>
> Sub Main()
> Set gfForm1=New Form1
> gfForm1.Show
> End Sub
I tried that. It shows the following messages then the CPU usage goes near
100%. gfForm1 is never shown. I replaced Form1 references in the code as
appropriate, i.e., changed 'Form1.Caption =' to 'gfForm1.Caption =':
Main called
Form_Load called, Form1 Load Counter = 1
I also used SubClass/UnSubClass code in the instance above. Also, I used a
Form2 instead of CreateWindowEx, then used gfForm1 instead of Form2. The
result above is when subclassing gfForm1. Here are my subclassing routines,
called in Form Load/Unload events:
Public Sub SubClassForm(ByVal h As Long)
m_hWnd = h
m_OldProc = SetWindowLong(h, GWL_WNDPROC, AddressOf FormWindowProc)
End Sub
Public Sub UnSubClassForm(ByVal h As Long)
If m_OldProc <> 0 Then
m_OldProc = SetWindowLong(h, GWL_WNDPROC, m_OldProc)
End If
End Sub
P.S.: I have been using VB since version 1.0, so I am not a beginner, not
that you thought I am...
"Sean Myers" <seanm@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:eEMv2HA0FHA.2932@xxxxxxxxxxxxxxxxxxxxxxx
> More of a guess than a genuine solution...(experts feel free to correct me
> :-) )
>
> I would guess that the form instance (Form1) crashes, but the O/S is still
> calling into that memory space, and the WindowProc attempts to access the
> instance Form1 which is crashed causing the second dialog with a messed up
> count. The program instability is likely caused by not unhooking your
> WindowProc properly on application shutdown. (Won't happen if you just let
> the application crash!)
>
> Several things you may wish to consider:
> 1) Use an explicit instance of Form1.
> in module:
> Public gfForm1 as Form1
>
> Sub Main()
> Set gfForm1=New Form1
> gfForm1.Show
> End Sub
>
> Check in your WindowProc to see if gfForm1 is nothing
>
> 2) Unhook your WindowProc on program termination.
> 3) Handle that error properly!
> I'm not sure what you mean by Err object instability. I have never
> experienced any problems with the Err object.
>
> HTH,
> Sean
>
.
- References:
- Err Object Anomaly Bug in VB6+SP5 and How to Reproduce
- From: Someone
- Re: Err Object Anomaly Bug in VB6+SP5 and How to Reproduce
- From: Sean Myers
- Err Object Anomaly Bug in VB6+SP5 and How to Reproduce
- Prev by Date: Re: Err Object Anomaly Bug in VB6+SP5 and How to Reproduce
- Next by Date: Re: Err Object Anomaly Bug in VB6+SP5 and How to Reproduce
- Previous by thread: Re: Err Object Anomaly Bug in VB6+SP5 and How to Reproduce
- Next by thread: Re: Err Object Anomaly Bug in VB6+SP5 and How to Reproduce
- Index(es):
Relevant Pages
|