BOOL CFormTextDlg::_FindWindows(CString wName)
{
//查找窗口
CWnd *hw;
int i=0;
hw = FindWindowEx(NULL,NULL,_T("#32770"),NULL); //查找C++窗口
CString str=_T(""),restr=_T("");
while(hw->GetSafeHwnd() != NULL)
{
hw->GetWindowTextW(str);
restr+=str+_T("/t");
if(str==wName)
{
i=1;break; //找到
}
hw=hw->GetWindow(GW_HWNDNEXT);
}
return i==1;
}
主窗口找到了,下面就是找主窗口里的控件了
CWnd *pbn=hw->FindWindowExW(hw->m_hWnd,NULL,NULL,_T("确定"));
//hw 就是上面所查找到的主窗口指针,这是查找命为确定的子窗口