• Delphi窗体研究,留个爪,以后回来研究


    Delphi - 窗体创建过程

     

    来自大富翁.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    1、TCustomForm.Create
       在 TCustomForm.Create 中调用 TCustomForm.CreateNew;
     
    2、TCustomForm.CreateNew;
       调用 FCanvas := TControlCanvas.Create;
       触发 TControlCanvas.Create;
       触发 TControlCanvas.CreateHandle;
     
    3、TControlCanvas.CreateHandle;
       调用 FControl.GetDeviceContext(FWindowHandle);
       即 TWinControl.GetDeviceContext(FWindowHandle);
     
    4、TWinControl.GetDeviceContext(FWindowHandle);
       调用 TWinControl.GetDC(Handle);
     
    此处说明一下:
       对 TWinControl 的 Handle 属性的读取会触发 TWinControl.GetHandle;
    可以察看 Property Handle; 的声明。
     
    5、第四步中对 Handle 进行读取,触发下述序列:(TWinControl)
        Handle->GetHandle->HandleNeeded
     
    6、TWinControl.HandleNeeded 检查 FHandle 的值:
      if FHandle = 0 then
      begin
        if Parent <> nil then Parent.HandleNeeded;
        CreateHandle; // 调用 CreateHandle;
      end;
     
    7、TWinControl.CreateHandle
       调用 CreateWnd;
       if FHandle = 0 then // 此时 FHandle 仍然为零
       begin
         CreateWnd;
         ...
       end;
     
    8、TWinControl.CreateWnd
       调用 CreateParams(Params);
       // 让用户有机会加入新的特征参数
       CreateParams(Params);
       with Params do
       begin
         ...
         // 标准的 API 使用,注册窗口类,CreateWindowEx ...
         if Windows.RegisterClass(WindowClass) = 0 then RaiseLastWin32Error;
         ...
         CreateWindowHandle(Params);
         ...
       end;
     
    9、CreateWindowHandle(Params);
       FHandle :=  CreateWindowEx(ExStyle, WinClassName, Caption, Style,
          X, Y, Width, Height, WndParent, 0, WindowClass.hInstance, Param);
       完成真正的窗口创建,并赋予 FHandle 窗口句柄。
     
    10、回到第一步
       CreateNew 之后调用 DoCreate
       try
         CreateNew(AOwner);
         ...
           if OldCreateOrder then DoCreate;
       finally
         ...
       end;
     
    11、DoCreate
        调用用户的 OnCreate 事件:
        if Assigned(FOnCreate) then
        try
          FOnCreate(Self); // 调用 OnCreate;
        except
          Application.HandleException(Self);
        end;
        if fsVisible in FFormState then Visible := True;

    我们OnCreate事件最后才触发的.

    http://www.cnblogs.com/huangjacky/archive/2010/01/08/1642413.html

  • 相关阅读:
    MySQL与Oracle数据库差异对比
    阿里ECS服务器远程桌面访问报错
    单分派和多分派
    博客主题
    论文阅读:LIC-Fusion: LiDAR-Inertial-Camera Odometry
    如何科研(自动化所 张世峰)
    读论文
    SLAM十四讲第二版项目代码总结
    LeetCode 982. Triples with Bitwise AND Equal To Zero
    论文阅读:Visual-Inertial Localization With Prior LiDAR Map Constraints
  • 原文地址:https://www.cnblogs.com/findumars/p/3498713.html
Copyright © 2020-2023  润新知