[ruby-talk:00183] finalizer help please

From: "Bryce" <crowdog@...>
Date: 1999-01-15 02:52:02 UTC
List: ruby-talk #183
Here is my code:

!!! start here
require 'WINGKR'
require 'final'
require 'delegate'

class WinControl
def initialize ()
  @createdFromHandle = false
  @handle = 0
  @autoDestroy = false

  @destructor = WinControl.destructor ( self )
  ObjectSpace.define_finalizer(self, @destructor )
end

def WinControl.destructor ( obj )
  lambda {
  require 'WINGKRUser32'

  print "\n\r destructor"
  print "\n\r obj is: ", obj.type
  print "\n\r obj value is: ", obj
  print "\n\r obj handle is: ", obj.handle
  if @handle != 0 then
   if DestroyWindow ( @handle ) != 0 then
    print "\n\r Destroyed: ", @handle
   else
    print "\n\r Could NOT destroy: ", @handle
   end
  end
  }
end

!!! end here

My problem is that the DestroyWindow function
does not get called and I get :
    undefined method 'DestroyWindow' for WinControl

However, the method DestroyWindow is defined in the
WINGKRUser32 module which I did 'require' in the
lambda {...}  section of the 'destructor'.

Could someone help on this please?

Thanks.
Bryce




In This Thread

Prev Next