在一个mfc程序中,如何得到另一个mfc程序的HWND?应该调用哪个函数?请各位大虾给予指教!!!!

解决方案 »

  1.   

    你可以用这些代码试试:CString strName;
    HWND OtherWnd=GetWindow(hWnd,GW_FIRSTWND);//hWnd为当前窗体的句柄
    while(OtherWnd!=NULL)
    {
        strName=GetWindowText(OtherWnd);
        if(strNmae==WindowTitle)   //WindowTitle为你要找的窗体的标题
           break;
        OtherWnd=GetNextWindow(OtherWnd);
    }
      

  2.   

    找QQ游戏大厅窗口句柄
    HWND HGAMEMAIN=FindWindowEx(NULL,0,"QQGame_MainFrame","QQGame");
      

  3.   

    hQQtemp=FindWindowEx(hDesktop,0,"QQGame_MainFrame","QQGame");
    dtgg=FindWindowEx(hQQtemp,0,"AfxWnd42","");
    dtgg=FindWindowEx(dtgg,0,"AfxWnd42","");
    dtgg=FindWindowEx(dtgg,0,"AfxOleControl42","");
    hQQtemp=dtgg;
    dtgg=FindWindowEx(dtgg,0,NULL,"");
    dtgg=FindWindowEx(hQQtemp,dtgg,NULL,"");
    dtgg=FindWindowEx(hQQtemp,dtgg,NULL,"");
    hsend=FindWindowEx(dtgg,0,"Button","");
    hsend=FindWindowEx(dtgg,hsend,"Button","");
    dtgg=FindWindowEx(dtgg,0,"ComboBox","");
    dtgg=FindWindowEx(dtgg,0,"Edit","");
    SendMessage(dtgg,WM_SETTEXT  ,(WPARAM) 0, (LPARAM) lpszbuff1); 
    以上为在QQ游戏大厅自动说话的代码