用FINDWINDOW 得到句柄 然后怎么遍历那个窗体上的所有控件?

解决方案 »

  1.   

    可以用 EnumWindow 查找它所有的子窗口
      

  2.   

    msdn:
    CWnd::GetWindow
    CWnd* GetWindow( UINT nCmd ) const;Return ValueReturns a pointer to the window requested, or NULL if none. The returned pointer may be temporary and should not be stored for later use.ParametersnCmdSpecifies the relationship between CWnd and the returned window. It can take one of the following values: GW_CHILD   Identifies the CWnd first child window.
    GW_HWNDFIRST   If CWnd is a child window, returns the first sibling window. Otherwise, it returns the first top-level window in the list.
    GW_HWNDLAST   If CWnd is a child window, returns the last sibling window. Otherwise, it returns the last top-level window in the list.
    GW_HWNDNEXT   Returns the next window on the window manager’s list.
    GW_HWNDPREV   Returns the previous window on the window manager’s list.
    GW_OWNER   Identifies the CWnd owner. 
      

  3.   

    枚举窗口
    BOOL EnumWindows(
      WNDENUMPROC lpEnumFunc,  // 回调函数的指针
      LPARAM lParam            // 应用程序定义的值
    );
    上面的函数中所用的回调函数
    BOOL CALLBACK EnumWindowsProc(
      HWND hwnd,      // 父窗口句柄
      LPARAM lParam   // 应用程序定义的值
    );
    枚举子窗口
    BOOL EnumChildWindows(
      HWND hWndParent,         // 父窗口句柄
      WNDENUMPROC lpEnumFunc,  // 回调函数的指针
      LPARAM lParam            // 应用程序定义的值
    );
    上面的函数中用到的回调函数
    BOOL CALLBACK EnumChildProc(
      HWND hwnd,      // 子窗口句柄
      LPARAM lParam   // 应用程序定义的值
    );
    具体应用,看一下MSDN吧!
    希望对你有帮助!