IE窗口比较特殊,你这样是找不到的,看看这个
////////////////////////////////////////////////////////////////
// MSDN Magazine -- August 2003
// If this code works, it was written by Paul DiLascia.
// If not, I don't know who wrote it.
// Compiles with Visual Studio .NET on Windows XP. Tab size=3.
//
// ---
// This class encapsulates the process of finding a window with a given class name
// as a descendant of a given window. To use it, instantiate like so:
//
// CFindWnd fw(hwndParent,classname);
//
// fw.m_hWnd will be the HWND of the desired window, if found.
//
class CFindWnd {
private:
//////////////////
// This private function is used with EnumChildWindows to find the child
// with a given class name. Returns FALSE if found (to stop enumerating).
//
static BOOL CALLBACK FindChildClassHwnd(HWND hwndParent, LPARAM lParam) {
CFindWnd *pfw = (CFindWnd*)lParam;
HWND hwnd = FindWindowEx(hwndParent, NULL, pfw->m_classname, NULL);
if (hwnd) {
pfw->m_hWnd = hwnd; // found: save it
return FALSE; // stop enumerating
}
EnumChildWindows(hwndParent, FindChildClassHwnd, lParam); // recurse
return TRUE; // keep looking
}
public:
LPCSTR m_classname; // class name to look for
HWND m_hWnd; // HWND if found
// ctor does the work--just instantiate and go
CFindWnd(HWND hwndParent, LPCSTR classname)
: m_hWnd(NULL), m_classname(classname)
{
FindChildClassHwnd(hwndParent, (LPARAM)this);
}
};