日期:2014-05-17  浏览次数:20780 次

关于API函数 FindWindowEx的问题~
本帖最后由 asd613613 于 2013-04-19 12:44:44 编辑
请问如何用FindWindowEx函数取得子窗体的句柄~
  IntPtr   ParenthWnd   =   new   IntPtr(0);   
                IntPtr   EdithWnd   =   new   IntPtr(0);
                IntPtr EdithWnd2 = new IntPtr(0);

            

                //查到窗体,得到整个窗体   
                ParenthWnd   =   FindWindow(null,"TeamViewer");
                //FindChildClassHwnd(hwndParent, IntPtr.Zero);
                //判断这个窗体是否有效   
                if   (!ParenthWnd.Equals(IntPtr.Zero))   
                {   
                      MessageBox.Show( "对话框存在 "); }
                  else 
              {MessageBox.Show( "对话框不存存在 ");} 
                          //得到User   Name这个子窗体,并设置其内容 
                

                EdithWnd = FindWindowEx(ParenthWnd, EdithWnd, "Edit", ""); 
                EdithWnd2 = FindWindowEx(ParenthWnd, EdithWnd, "Edit", null);//获取EDIT句柄 密码
                if (!EdithWnd.Equals(IntPtr.Zero))
                {
                    StringBuilder sb = new StringBuilder(1024);
                    SendMessage(EdithWnd, WM_GETTEXT, sb.Capacity, sb);
                    
                    MessageBox.Show(sb.ToString());
                    SendMessage(EdithWnd2, WM_GETTEXT, sb.Capacity, sb);
         &nbs