FindControl什么时候才会使用ObjectFromHWnd函数呢?——VCL很难调试,加一个日志函数,记录时间
2015-08-21 18:39
597 查看
IsDelphiHandle
FindVCLWindow
function IsVCLControl(Handle: HWND): Boolean;
function FindControl(Handle: HWND): TWinControl;
function FindVCLWindow(const Pos: TPoint): TWinControl;
我测了一下,无论是拖控件放到窗体上,还是动态生成的控件,都是通过GetProp方法取得Delphi对象的指针。那么什么时候会使用神乎其神的ObjectFromHWnd函数呢?
线索还是点击TButton后发生,因为李维的书上提到了这一点~
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后发生,因为李维的书上提到了这一点~
相关文章推荐
- [hive]InvalidObjectException(message:Role admin already exists.)
- android Error occurred during initialization of VM Could not reserve enough space for object heap Could not create the Java virtual machine.
- GCD学习
- ObjectAnimator不包含百分比移动的替代方法
- 在xcode 6.4 中使用swift和object-c混合编程,同时通过cocoapods进行管理的一些问题和解决办法
- WaitForSingleObject函数用法及互斥对象的理解 .
- 黑马程序员--Objective-C Block学习
- 黑马程序员--Objective-C 中类的理解
- Objective-C 【self的用法】
- Objective-C 【self的用法】
- objective-c宏定义
- javaScript中利用ActiveXObject来创建FileSystemObject操作文件
- poj 3241 Object Clustering 莫队算法,曼哈顿最小生成树
- BOM——浏览器对象模型(Browser Object Model)
- Object-C 中各数据类型转换 NSData转NSString,Byte,UIImage
- <转载>html标签之Object和EMBED标签详解
- Objective-C 学习笔记(Day 3,下)
- Objective-C 学习笔记(Day 3,下)
- [iOS备忘录]BLE测试传输速度[objectiv-c]
- java的eclipse操作和常用类Object的使用