比如系统中有一个程序 abc.exe 正在运行, 运行的窗体的句柄为 hwnd1
这个窗体弹出了一个 messagebox window (弹出窗口是父窗口的 OwnedWindow)我通过自己的 C# 程序, 已经通过 findwindow 函数得到了 hwnd1 这个句柄,
但是我该如何知道 hwnd1 下是否有 OwnedWindow 呢?不知道调用 WINAPI 什么函数,可能根本就不存在这样的函数,望高手不吝赐教,100分薄礼,谢谢大家!

解决方案 »

  1.   

    GetWindow(MDIhwnd,   GW_CHILD)获得子窗体句柄
    EnumChildWindows(hWndParent,myEnumChild,0); 
    hWndParent 枚举子窗口的父窗口的句柄 
      

  2.   


    应该是 getchild 的功能吧
    不是 getparent可惜 api 里面没有 getchild 的函数
      

  3.   

    EnumChildWindows因为 Child 不只一个。
      

  4.   


    所有者窗口无法用 GW_CHILD 取得吧。
    应该是类似 GW_OWNEDWINDOW 之类的功能,可惜api中好像没有
      

  5.   


    用 Spy ++ 看了,根本没有弹出对话框的子窗口句柄,所以用EnumChildWindows肯定找不到
      

  6.   

    引用 1 楼 caozhy 的回复:GetParentWindow
    应该是 getchild 的功能吧
    不是 getparent可惜 api 里面没有 getchild 的函数
      

  7.   

    .NET 3.0以上应该可以通过OwnedWindows属性获取到吧
    foreach (Window ownedWindow in this.OwnedWindows)
    {
        Console.WriteLine(ownedWindow.Title);
    }
      

  8.   

    你用了findwindow,居然没想到用findwindowex
    HWND FindWindowEx(          HWND hwndParent,
        HWND hwndChildAfter,
        LPCTSTR lpszClass,
        LPCTSTR lpszWindow
    );hwndParent
    [in] Handle to the parent window whose child windows are to be searched.