如何找到当前活动窗口上的一些子控件(比如编辑框)?? FindWindowEx函数,看看msdn就可以了 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 一个演示: char* FindIEURL() { HWND hWorker,hRebar,hComEx,hcom,hEdit; HWND hwndParent=::FindWindow("IEFrame",NULL); //找到最近的IE. if(hwndParent == NULL)//没有IE运行 return NULL; char szURL[260]; hWorker=::FindWindowEx(hwndParent,0,"WorkerA",NULL);//找到工作区 if(hWorker == NULL)//用户用NT hWorker=::FindWindowEx(hwndParent,0,"WorkerW",NULL);//WindowNT中的ie hRebar=::FindWindowEx(hWorker,0,"ReBarWindow32",NULL);//找到Rebar hComEx=::FindWindowEx(hRebar,0,"ComboBoxEx32",NULL);//找到Comboboxex hcom=::FindWindowEx(hComEx,0,"ComboBox",NULL);//找到combobox hEdit=::FindWindowEx(hcom,0,"Edit",NULL);//找到ComBoBox的edit控件句柄 //如果使用::SendMessage(hEdit,WM_GETTEXT,260,(LPARAM) szURL); //将无法获得未浏览的IE地址栏的输入,还有其他一些问题.. DWORD result; ::SendMessageTimeout(hEdit, WM_GETTEXT, 260, szURL, 0, 1000, &result); return szURL;} GetWindow(GW_CHILD,查msdn吧, 还是帖出来吧HWND hWndChild = ::GetWindow(pWnd->m_hWnd, GW_CHILD); if (hWndChild != NULL) { for (; hWndChild != NULL; hWndChild = ::GetNextWindow(hWndChild, GW_HWNDNEXT)) { CWnd *pChild=CWnd::FromHandle(hWndChild); CString strClass; ::GetClassName(hWndChild,strClass.GetBufferSetLength(256),256); strClass.ReleaseBuffer(); if(strClass.CompareNoCase("Edit")==0) { //edit else { //other } } } 也可以用EnumChildWindows,遍厉所有的子窗口 菜鸟学习VC++6.0求解 为什么一定要包含“stdafx.h” VC做一个Agent取得SQL Server2000的信息,请大家给方案!谢谢 新手请教:像串口调试助手那种接受数据的窗口是什么控件? 如何判断打印机是否可用,有什么类和函数吗 error C2146 fatal error C1004 关于对话框的问题 如何在BIOS级别对文件进行操作??? 111 请帮帮忙。 关于pdf文件的,如何将禁止打印的pdf文件打印出来,如果解决了我一定给分啊 编译微软自己的程序竟然会出错!?
{ HWND hWorker,hRebar,hComEx,hcom,hEdit; HWND hwndParent=::FindWindow("IEFrame",NULL);
//找到最近的IE. if(hwndParent == NULL)//没有IE运行
return NULL; char szURL[260]; hWorker=::FindWindowEx(hwndParent,0,"WorkerA",NULL);//找到工作区 if(hWorker == NULL)//用户用NT
hWorker=::FindWindowEx(hwndParent,0,"WorkerW",NULL);//WindowNT中的ie hRebar=::FindWindowEx(hWorker,0,"ReBarWindow32",NULL);//找到Rebar hComEx=::FindWindowEx(hRebar,0,"ComboBoxEx32",NULL);//找到Comboboxex hcom=::FindWindowEx(hComEx,0,"ComboBox",NULL);//找到combobox hEdit=::FindWindowEx(hcom,0,"Edit",NULL);//找到ComBoBox的edit控件句柄 //如果使用::SendMessage(hEdit,WM_GETTEXT,260,(LPARAM) szURL);
//将无法获得未浏览的IE地址栏的输入,还有其他一些问题..
DWORD result;
::SendMessageTimeout(hEdit,
WM_GETTEXT,
260,
szURL,
0,
1000,
&result); return szURL;
}
查msdn吧,
if (hWndChild != NULL)
{
for (; hWndChild != NULL;
hWndChild = ::GetNextWindow(hWndChild, GW_HWNDNEXT))
{
CWnd *pChild=CWnd::FromHandle(hWndChild);
CString strClass;
::GetClassName(hWndChild,strClass.GetBufferSetLength(256),256);
strClass.ReleaseBuffer();
if(strClass.CompareNoCase("Edit")==0)
{
//edit
else
{
//other
}
}
}