zoukankan      html  css  js  c++  java
  • FindControl什么时候才会使用ObjectFromHWnd函数呢?——VCL很难调试,加一个日志函数,记录时间

    IsDelphiHandle
    FindVCLWindow
    function IsVCLControl(Handle: HWND): Boolean;
    function FindControl(Handle: HWND): TWinControl;
    function FindVCLWindow(const Pos: TPoint): TWinControl;

    function FindControl(Handle: HWnd): TWinControl;
    var
      OwningProcess: DWORD;
    begin
      Result := nil;
      if (Handle <> 0) and (GetWindowThreadProcessID(Handle, OwningProcess) <> 0) and
         (OwningProcess = GetCurrentProcessId) then
      begin
        if GlobalFindAtom(PChar(ControlAtomString)) = ControlAtom then
          Result := Pointer(GetProp(Handle, MakeIntAtom(ControlAtom)))
        else
          Result := ObjectFromHWnd(Handle);
      end;
    end;
    
    function ObjectFromHWnd(Handle: HWnd): TWinControl;
    var
      OwningProcess: DWORD;
    begin
      if (GetWindowThreadProcessID(Handle, OwningProcess) <> 0) and
         (OwningProcess = GetCurrentProcessID) then
        Result := Pointer(SendMessage(Handle, RM_GetObjectInstance, 0, 0))
      else
        Result := nil;
    end;

    我测了一下,无论是拖控件放到窗体上,还是动态生成的控件,都是通过GetProp方法取得Delphi对象的指针。那么什么时候会使用神乎其神的ObjectFromHWnd函数呢?

    线索还是点击TButton后发生,因为李维的书上提到了这一点~

  • 相关阅读:
    XtraFinder在OSX10.11的使用
    meterpreter > migrate 1548
    meterpreter > ps
    meterpreter > sysinfo
    meterpreter > screenshot
    ubuntu
    一次真是渗透
    nmap -sT -A --script=smb-check-vulns -PO 172.16.21.170
    use scanner/smb/smb_version
    scanner/portscan/syn
  • 原文地址:https://www.cnblogs.com/findumars/p/4748730.html
Copyright © 2011-2022 走看看