I have a user who encountered an Illegal Cast exception in this code, and I can’t figure out why it would happen. This code is in App.Activate, and there were two windows open when this exception was raised. One was a DisplayWnd, the other was a CountWnd, and they’re not related except that both might reference the same Info object.
Does anyone have any suggestions for possible scenarios that could cause this exception?
Here’s the code in App.Activate:
================
dim x as integer
dim ThisInfo as Info
if WindowCount>0 then
for x=WindowCount-1 downto 0
if Window(x)<>nil then
if Window(x) isa DisplayWnd then 'DisplayWnd is a document-type window
if DisplayWnd(Window(x)).Closing=False then '.Closing is a property of DisplayWnd class, it is set when the window's CancelClose event is raised
if DisplayWnd(Window(x)).MyInfo<>nil then '.MyInfo is a property of DisplayWnd
ThisInfo=DisplayWnd(Window(x)).MyInfo
if DisplayWnd(Window(x)).Closing=False then <========= ILLEGAL CAST EXCEPTION IS RAISED HERE
================
I can simply put a try/catch around the center of the code to solve the immediate problem, but I’d like to understand why this exception would ever be raised.
Thanks!
- John