EnumWindow() and EnumChildWindow()配合回调函数,可以取得所有的句柄。

解决方案 »

  1.   

    我已经找到某个窗体了:
    如:
     var HWD:THandle;
    begin
      HWD:=FindWindow('','某个窗体的标题');
      if HWD<>0 then
      begin
        //我想找这个窗体中其它的,不太需要子窗体的句柄。
        //比如一个登陆窗体,有Edit,Button,
        //我是想找到Edit.Handle,Button.Handle
      end;
    end;
      

  2.   

    看看我写的一个程序aimtartet(csdn上有),用了递归调用来枚举某个窗口下的所有窗口
      

  3.   

    例如:
    HWND hTopParentWnd;//指定的窗口
    EnumChildWindows(hTopParentWnd, EnumSetChild, NULL);//调用
    //------------------------------------------------
    //名称:EnumSetChild
    //描述:枚举并设置m_cWndTree的位置
    //------------------------------------------------BOOL CALLBACK EnumSetChild(HWND hwnd, LPARAM lParam)
    {
    if(::GetParent(hwnd) != hTopParentWnd)
    return TRUE;
    CString strWndName, strHandle, strCaption;
    CFindIEDlg *pDlg = (CFindIEDlg *)AfxGetMainWnd();
    ::GetClassName(hwnd, strWndName.GetBuffer(50), 100);
    _itoa((int)hwnd, strHandle.GetBuffer(20), 16);   //得到窗口的类名
        ::GetWindowText(hwnd, strCaption.GetBuffer(50), 50);
    strCaption.ReleaseBuffer();
    strWndName.ReleaseBuffer();
    strHandle.ReleaseBuffer();
    strHandle.MakeUpper();
    strHandle += "[" + strCaption + "]"+ strWndName;
    //-------------------------------------递归算法
              hTopParentWnd = hwnd;
    EnumChildWindows(hwnd, EnumSetChild, NULL);   
    hTopParentWnd = ::GetParent(hwnd);      
    //------------------------------------
    return TRUE;
    }
      

  4.   

    关注,有源码给我一份喔
    email:[email protected]