Slimelite BBS

Object Inheritance

Back to SUPRA

From Matthew O Donnell · 1996-04-12 07:00 · #77738 in SUPRA

Hello this is my first message to this conferance and I am hoping that you
people can help me.

My problem is that I am creating my own window object and in this I inherit
the intution window object, somthing like this:

OBJECT mywindow OF window
/* My extra data goes in here */
ENDOBJECT

Okay this works fine. I then write some methods for my procedure. The methods
that i have written so far are:

PROC open() OF mywindow
/* This method opens the window */
ENDPROC

PROC close() OF mywindow
/* This method closes the window */
ENDPROC

PROC wait4message() OF mywindow
/* This method handle the message loop for the window */
ENDPROC

So now I have my object ready to use so in my main procedure I do this.

PROC main()
   DEF w: PTR TO mywindow

   NEW w
   w.open()
   w.wait4message()
   w.close()
   END w
ENDPROC

The program compiles fine but when I run the program the window opens and
then the computer crashes. The crash happens in the w.wait4message() method.
However, the cause of the problem is when I use the command

   self := OpenWindowTagList( etc... )

in the open method.

So what happens in the main procedure I allocate some memory for w using
NEW, then in the open procedure OpenWindowTagList allocates its own memory
for the window instead of using the memory that I have already got using the
NEW command. So when the method returns to the main procedure and runs the
wait4message() method w does not point to the window, it points to a blank
space in memory. So my question is how do i get around this problem without
having to change my object to:

OBJECT mywindow
   window: PTR TO window,
   /* rest of my data */
ENDOBJECT

Thanks in advance for any help that anybody can give me.

                     Matthew

--- Blue Wave v1.0
 * Origin: Xstream 44-151-488-0698 V21-V34 [OS2/Max3.00/Md1.02e] (2:250/210)