whats new ¦  programming tips ¦  indy articles ¦  intraweb articles ¦  informations ¦  links ¦  interviews
 misc ¦  tutorials ¦  Add&Win Game

Tips (1547)

Database (90)
Files (137)
Forms (107)
Graphic (115)
IDE (21)
Indy (5)
Internet / LAN (131)
IntraWeb (0)
Math (76)
Misc (127)
Multimedia (45)
Objects/
ActiveX (51)

OpenTools API (3)
Printing (35)
Strings (83)
System (268)
VCL (243)

Top15

Tips sort by
component


Search Tip

Add new Tip

Add&Win Game

Advertising

35 Visitors Online


 
...find classes registered by a form class?
Autor: Peter Below
Homepage: http://www.teamb.com
[ Print tip ]  

Tip Rating (3):  
     


type
  
PFieldClassTable = ^TFieldClassTable;
  TFieldClassTable = packed record
    
Count: Smallint;
    Classes: array[0..8191] of ^TPersistentClass;
  end;

function GetFieldClassTable(AClass: TClass): PFieldClassTable; assembler;
asm
        
MOV     EAX,[EAX].vmtFieldTable
        OR      EAX,EAX
        JE      @@1
        MOV     EAX,[EAX+2].Integer
@@1:
end;

procedure TForm1.Button1Click(Sender: TObject);

  procedure Display(const S: string);
  begin
    
memo1.Lines.Add(S);
  end;
  
var
  
pFCT: PFieldClassTable;
  aClass: TClass;
  i: SmallInt;
begin
  
memo1.Clear;
  aClass := Classtype;
  while aClass <> TPersistent do 
  begin
    
Display('Registered classes for class ' + aClass.ClassName);
    pFCT := GetFieldClasstable(aClass);
    if not Assigned(pFCT) then
      
Display('  No classes registered')
    else 
    begin
      
Display(Format('  %d classes registered', [pFCT^.Count]));
      for i := 0 to pFCT^.Count - 1 do
        
Display('  ' + pFCT^.Classes[i]^.ClassName);
    end;
    aClass := aClass.ClassParent;
  end
end
;


 

Rate this tip:

poor
very good


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners