title: Add a property on TWinControl Class
body: <p>I want to add a published property into TWinControl.
  Is there someway to do this without the necessity of recompiling the base source code ?</p>
  
  <p>If not, some way to recompile the base source code without too much troubles ?</p>
  
  <p>Tks in advice... </p>
  
  <p><em>EDIT 'CAUSE OF NEW IDEAS</em></p>
  
  <p>Alright, What I'm thinking to do I'm trying to override the _GetMem from System.pas for classes 
  inherited from TWinControl. 
  Why ? 'Cause I'll alloc some extra space to the objects enough to an integer.
  Why an integer ? 'Cause this way I can add any pointer to object. 
  So on the helper class to TWinControl I can make a Get an Set function to access this space of memory. 
  Good isn't it ? How to do this ? 
  Overrideing the GetMem procedure I can use the same strategy used on FastCode, create a jumper to the new procedure. </p>
  
  <p>What I need now is understand how this memory alloc works InstanceSize to override this. 
  At all I'm studding how do Delphi do this... And to add this on DFM I will do the same way, I'll create a jumper to the filer.</p>
  
  <p>Someone have some idea to add the new space in objects ? What method I need to override ? The jumper I know how to do.</p>
  
  <p>Tks Again.</p>
  
  <p>EDIT = Evolution</p>
  
  <p>I think that I did the injection of memory. 
  I need to do more tests.
  I've just did it, I'm not caring about optimizations at the moment, if some one would like to test it, here goes the code.
  Just add the unit as the first unit of your project.</p>
  
  <pre><code>unit uMemInjection;
  
  
  interface
  
  uses
    Controls;
  
  type
    THelperWinControl = class Helper for TWinControl
    private
      function RfInstanceSize: Longint;
      function GetInteger: Integer;
      procedure SetInteger(const Value: Integer);
    public
      property RfInteger: Integer read GetInteger write SetInteger;
    end;
  
  implementation
  
  uses
    Windows;
  
  procedure SInstanceSize;
  asm
    call TWinControl.InstanceSize
  end;
  
  function THelperWinControl.GetInteger: Integer;
  begin
    Result := Integer(PInteger(Integer(Self) + (Self.InstanceSize - SizeOf(Integer)))^);
  end;
  
  function THelperWinControl.RfInstanceSize: Longint;
  begin
    Result := PInteger(Integer(Self) + vmtInstanceSize)^;
    Result := Result + SizeOf(Integer);
  end;
  
  /////////////////////////////////////////////// FastCode ///////////////////////////////////////////////
  type
    PJump = ^TJump;
    TJump = packed record
      OpCode: Byte;
      Distance: Pointer;
    end;
  
  function FastcodeGetAddress(AStub: Pointer): Pointer;
  begin
    if PBYTE(AStub)^ = $E8 then
    begin
      Inc(Integer(AStub));
      Result := Pointer(Integer(AStub) + SizeOf(Pointer) + PInteger(AStub)^);
    end
    else
      Result := nil;
  end;
  
  procedure FastcodeAddressPatch(const ASource, ADestination: Pointer);
  const
    Size = SizeOf(TJump);
  var
    NewJump: PJump;
    OldProtect: Cardinal;
  begin
    if VirtualProtect(ASource, Size, PAGE_EXECUTE_READWRITE, OldProtect) then
    begin
      NewJump := PJump(ASource);
      NewJump.OpCode := $E9;
      NewJump.Distance := Pointer(Integer(ADestination) - Integer(ASource) - 5);
  
      FlushInstructionCache(GetCurrentProcess, ASource, SizeOf(TJump));
      VirtualProtect(ASource, Size, OldProtect, @OldProtect);
    end;
  end;
  
  /////////////////////////////////////////////// FastCode /////////////////////////////////////////////// 
  
  
  { THelperWinControl }
  procedure THelperWinControl.SetInteger(const Value: Integer);
  begin
    PInteger(Integer(Self) + (Self.InstanceSize - SizeOf(Integer)))^ := Value;
  end;
  
  initialization
    FastcodeAddressPatch(FastcodeGetAddress(@SInstanceSize), @TWinControl.RfInstanceSize);
  
  
  end.
  </code></pre>