The FindWindow function retrieves a handle to the top-level window whose class name and window name match the specified strings. This function does not search child windows. This function does not perform a case-sensitive search.Tpage虽然不是最顶层窗口,但是是显示出来的主窗口。
查找到Tpage的窗口句柄wndTpage后,可以如下操作:
HWND hwnd1 = ::GetWindow(wndTpage,GW_CHILD);//查找子窗口
HWND hwnd2 = ::GetWindow(hwnd1,GW_CHILD);   //查找子窗口
HWND hwnd3 = ::GetWindow(hwnd2,GW_CHILD);   //查找子窗口,得到Edit控件句柄。
如果hwnd2窗口内是有多个子控件,可以继续如下查找:
char strBuff[256]; 
hChildWnd=hwnd3;   
while(hChildWnd!=NULL){   
  ::GetClassName(hChildWnd,strBuff,256);   
  hChildWnd=::GetNextWindow(hChildWnd,GW_HWNDNEXT);//查找下一个子控件 
}

解决方案 »

  1.   

    FindowWindowEx的第1个参数指定在哪个窗口中查找,Edit控件不在这个“主”窗口中。
      

  2.   

    HWND FindWindowEx(
      HWND hwndParent,      // handle to parent window
      HWND hwndChildAfter,  // handle to a child window
      LPCTSTR lpszClass,    // pointer to class name
      LPCTSTR lpszWindow    // pointer to window name
    );

    hwndChildAfter 
    Handle to a child window. The search begins with the next child window in the Z order. The child window must be a direct child window of hwndParent, not just a descendant window. 
    If hwndChildAfter is NULL, the search begins with the first child window of hwndParent. 
    Note that if both hwndParent and hwndChildAfter are NULL, the function searches all top-level and message-only windows. 
      

  3.   

    遍历子窗口可以用EnumChildWindows。
    用FindWindowEx遍历子窗口,在获取了第一个子窗口句柄后拿它做为第二个参数,找到第二个子窗口,然后以此类推遍历下去。