![]() |
Instanzieren von Komponenten
Mich beschäftigt grad eine Frage.
Wo im Code werden eigentlich Komponenten bei Ausführung des Programm erzeugt. Ich meine, ich lege irgendein Control zur Design Time auf ein Formular. Von der Klasse muss ja irgendwann zur Laufzeit eine Instanz erstellt werden, und ich denke auch die Stele gefunden zu haben, nämlich der Constructor von TWinControl, wo ein MakeObjectInstances aus der Unit Classes aufgerufen wird. Dazu hier mal der Code. Aber verstehen tu ich den nicht. Also was passiert da im Hintergrund:
Delphi-Quellcode:
function MakeObjectInstance(Method: TWndMethod): Pointer;
const BlockCode: array[1..2] of Byte = ( $59, { POP ECX } $E9); { JMP StdWndProc } PageSize = 4096; var Block: PInstanceBlock; Instance: PObjectInstance; begin if InstFreeList = nil then begin Block := VirtualAlloc(nil, PageSize, MEM_COMMIT, PAGE_EXECUTE_READWRITE); Block^.Next := InstBlockList; Move(BlockCode, Block^.Code, SizeOf(BlockCode)); Block^.WndProcPtr := Pointer(CalcJmpOffset(@Block^.Code[2], @StdWndProc)); Instance := @Block^.Instances; repeat Instance^.Code := $E8; { CALL NEAR PTR Offset } Instance^.Offset := CalcJmpOffset(Instance, @Block^.Code); Instance^.Next := InstFreeList; InstFreeList := Instance; Inc(Longint(Instance), SizeOf(TObjectInstance)); until Longint(Instance) - Longint(Block) >= SizeOf(TInstanceBlock); InstBlockList := Block; end; Result := InstFreeList; Instance := InstFreeList; InstFreeList := Instance^.Next; Instance^.Method := Method; end; |
Re: Instanzieren von Komponenten
Zitat:
|
Re: Instanzieren von Komponenten
Zitat:
Zitat:
|
Re: Instanzieren von Komponenten
Zitat:
|
Re: Instanzieren von Komponenten
Alles klar, jetzt hab wirds klarer. Vielen Dank :thumb:
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 10:26 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz