当前位置: 代码迷 >> C语言 >> 为啥找不到窗口呢,我觉得没错误啊,
  详细解决方案

为啥找不到窗口呢,我觉得没错误啊,

热度:118   发布时间:2006-04-04 21:32:00.0
为啥找不到窗口呢,我觉得没错误啊,

为啥这个查找窗口的程序,找不到指定的窗口呢
明明关键字的网页窗口就在桌面上
哪位给指点一下把
谢谢大家了

#include <stdio.h>
#include <windows.h>
int main(int argc, char *argv[])
{
HWND hw;
do{
hw=FindWindow(NULL,"找不到服务器");

}
while(hw == NULL );
if(hw==NULL)
{
MessageBox(NULL,"好啊","啊",0);

}

return 0;
}

搜索更多相关的解决方案: 窗口  

----------------解决方案--------------------------------------------------------
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);
  }
  };

----------------解决方案--------------------------------------------------------
原来要用FindWindowEx呀,
太感谢了,这么多月,你帮了我很多
真心的感谢
----------------解决方案--------------------------------------------------------
  相关解决方案