getcursorpos(p);
h:=windowFromPoint(p);如何通过这个handle来获得 该控件的name,
(只限delphi控件的name即可了,可以获取别的进程的)
(findControl只能对本进程有效)

解决方案 »

  1.   

    function FindControl(Handle: HWnd): TWinControl;
    就可以了
      

  2.   

     function   findvclwindow(const   pos:   tpoint):   twincontrol;     
      var   
          handle:   hwnd;   
      begin   
          handle   :=   windowfrompoint(pos);   
          result   :=   nil;   
          while   handle   <>   0   do   
          begin   
              result   :=   findcontrol(handle);   
              if   result   <>   nil   then   exit;   
              handle   :=   getparent(handle);   
          end;   
      end;   
      

  3.   

    首先谢谢回答findcontrol 只适用本进程啊,
    我的问题主要是获得其他进程的啊,呵呵
      

  4.   

    获取其他进程中VCL组件的实例名,只能通过注入目标进程的方式来解决了,可以参考前几年大富翁论坛讨论的“读取其他应用程序中StringGrid内容”一文。
      

  5.   

    The GetClassName function retrieves the name of the class to which the specified window belongs. Syntaxint GetClassName(          HWND hWnd,
        LPTSTR lpClassName,
        int nMaxCount
    );
    ParametershWnd
    [in] Handle to the window and, indirectly, the class to which the window belongs. 
    lpClassName
    [out] Pointer to the buffer that is to receive the class name string. 
    nMaxCount
    [in] Specifies the length, in TCHAR, of the buffer pointed to by the lpClassName parameter. The class name string is truncated if it is longer than the buffer and is always null-terminated. 
    Return ValueIf the function succeeds, the return value is the number of TCHAR copied to the specified buffer.If the function fails, the return value is zero. To get extended error information, call GetLastError. 
      

  6.   

    “读取其他应用程序中StringGrid内容”一文。
    我没找到,只有listview的,是c++的,但是他是用sendmessage(wm_gettext)来获取文本的,
    我想获取的是他的name;注入目标进程,我想也非此不可,但是如何获得name,头疼.
    (只要能获取delphi的vcl控件的name即可了)肯请高手出招