Enrico,
>You are calling a FWH level method that, in turn, calls some Windows API level functions using an invalid handle. There are no runtime errors for such situations.
OK, but the FW code in the Display() method is still getting executed, thus the error. So how do we prevent the program from crashing?
On the surface it seems to be a Catch-22, you can't prevent the Display() method from being called until the window is closed and you can't (rather don't want to) close the window until you end the recordset and ending the recordset causes the Display method to be called (under some circumstances).
So, the solution seems to be, as Rao suggested, modifying the XBrowse source to prevent the Paint method from being called when a flag is set. This way we could set the flag, end the recordset, then close the window.
I just noticed that the flag Rao suggested (lCreated) is already in my version of Xbrowse.prg's Display() method. So if you change my test to:
define button of oBar action ( oBrw:=.f., oBrw:End(), oBrw:setArray({}), oBrw:display() )
No more error!
Thanks Rao!
Rick, please check if your version of the Display() method looks like this:
METHOD Display() CLASS TXBrowse
if !::lCreated
return nil
endif
::BeginPaint()
::Paint()
::EndPaint()
return 0
If it doesn't, make it so. And then try testing this by setting oBrw:=.f. before ending the recordset. Let us know.
James