HELP:==> BP7.0 Protected Mode

OK Guys, here is a really big problem I have with converting a (VERY) large Real mode progrram to Protected mode.

I would really like some information as to why the following errors are occuring, because after three weeks, I have absolutely no idea...


  I have my own object of type TWINDOW, and I cannot access the SELF variable. The INIT constructor looks like:

      CONSTRUCTOR TFILEWINDOW.INIT(var Bounds: TRect.....)
        inherited Init(Bounds, ATitle, wnNoNumber)
        Options := Options or ofTileable;

        { This is the line that causes a General Protection Fault }
        FileWindow := @Self;

File Window is a global variable of type PFileWindow and local to this unit. {*word*81}red if I know why this doesn't work.


OK, this is another niggling little bug. Again, it is to do with objects and causes a General protection Fault...

UNIT .....



           TINFOVIEW =  object(TView)
                ByteCount: LongInt;
                WidthByte, SortOption: Byte;

                constructor Init(var Bounds: TRect);
                function      GetPalette: PPalette;  virtual;
                procedure   Draw;  virtual;
                procedure   UpdateSort(ASort, AWidth: Byte);
                procedure   HandleEvent(var Event: TEvent); virtual;

       VAR  gblSortOption, SortOption: Byte;   { Global to this unit }
           gblWidthByte: Byte;


     { This constructor can access it's own variable just fine }
     CONSTRUCTOR TINFOVIEW.INIT(var Bounds.......)
        inherited Init(Bounds);
        SortOption := gblSortOption;      { This line works }
        WidthByte := gblWidthByte;

     var A: Byte;   { This is here for testing purposes }
        SortOption := ASort;   { This causes a General Protection Fault }
        A := ASort;             { This line is fine, no errors! }
        WidthByte := AWidth;  { I don't remember if this line works or not. }


I have an object based on  TWindow that itself does no handlling of and mouse events. In other words, the inherited HandleEvent (TWindow) will handle all mouse events.

The object works 100% until the mouse is moved over the window. The mouse  can be moved anywhere else, but as soon as the mouse runs into the window, I get a General Protection Fault. Why? I don't really know.

This progam has been working fine in Real mode for years, but once it is compiled in protected mode, it starts working funny.  (Even ReadKey caused the program to hang once...}  I would really like to understand what the DPMI server is thinking when this happens, so any help would be appreciated.