Delphi启动过程追踪

第一步:

_InitExe windows调用Exe的入口

_StartExe

InitUnits

第二步:

InitControls的initialization部分

TApplication.Create

AllocateHWnd

AllocateHWnd

MakeObjectInstance

StdWndProc

Instance^.FMethod := TMethod(AMethod);

AMethod==首次创建App时对应PopupControlProc

PMethod = ^TMethod;
``TMethod = record Code, Data: Pointer; public class operator Equal(const Left, Right: TMethod): Boolean; inline; class operator NotEqual(const Left, Right: TMethod): Boolean; inline; class operator GreaterThan(const Left, Right: TMethod): Boolean; inline; class operator GreaterThanOrEqual(const Left, Right: TMethod): Boolean; inline; class operator LessThan(const Left, Right: TMethod): Boolean; inline; class operator LessThanOrEqual(const Left, Right: TMethod): Boolean; inline; end;

第三部:

  • Application.Initialize;
  • Application.Run;

第四步:

  • HandleMessage

  • TApplication.ProcessMessage

  • PeekMessage

  • TranslateMessage

  • DispatchMessageWi->

  • StdWndProc

  • TWinControl.MainWndProc

  • WindowProc: TWndMethod【TControl】

  • TControl.WndProc【初始化时指定FWindowProc := WndProc;】

  • TControl.WndProc

  • procedure TCustomForm.WndProc(var Message: TMessage);

  • 基于多态性调用父类TControl的WndProc

  • Dispatch->TObject.Dispath->消息回调函数

  • DefaultHandler

项目编译时,跳过资源编译的编译选项

<SkipResGeneration>true</SkipResGeneration>

posted @ 2020-02-23 21:05  windlog  阅读(209)  评论(0编辑  收藏  举报