比如我用FindWindow找到某个窗口,我想取得其中某个编辑框的句柄,进而用GetWindowText取得编辑框的文字,如何实现?

解决方案 »

  1.   

    用FindWindowEx 啊
    或者
    GetWindow + GetNextWindow 
    或者
    GetDlgItem
    ...
      

  2.   

    你要能知道这个EDIT的ID才行
    ::GetDlgItem(hWndParent,ID_EDIT)->SetWindowText如果不知道,可以用EnmuChildWindows来枚举来找出这个编辑框,
    如果只有一个这种编辑框,那么用GetClassName就可以过滤出来
    不然还得加上其他特征来过滤出,比如位置大概在哪里之类的... 呵呵
      

  3.   

    EnumChildWindows这个方法在MSDN里查不到??
      

  4.   

    不是自己写的控件的id可不好知道!!用spy++看它的类什么的!然后找!
    EnumChildWindows遍历所有子控件!!一个一个判断!判断的条件就看你自己的了
      

  5.   

    用Spy++可以看到控件ID, 然后GetDlgItem
      

  6.   

    注意:跨进程不能用GetWindowText得到编辑框的内容,要用WM_GETTEXT消息。
      

  7.   

    EnumChildWindows这个方法在MSDN里查不到??
    -----------------------
    The EnumChildWindows function enumerates the child windows that belong to the specified parent window by passing the handle to each child window, in turn, to an application-defined callback function. EnumChildWindows continues until the last child window is enumerated or the callback function returns FALSE
    BOOL EnumChildWindows(          HWND hWndParent,
        WNDENUMPROC lpEnumFunc,
        LPARAM lParam
    );
    Header Declared in Winuser.h, include Windows.h 
    Import library User32.lib 
    Minimum operating systems Windows 95, Windows NT 3.1 
      

  8.   

    用Spy++怎么查控件的ID?
    我打开了一个ie,进入新浪主页,然后在Spy++里找到这个进程。比如我想知道新浪主页最上面那个登陆邮箱输入用户名的EditBox,怎样操作?
      

  9.   

    webbrowser控件的编辑框没那么容易取得,
    并不是webbrowser的子窗口