如何获取程序中的Internet Explorer_Server 孙子窗口???

MEFULEU 2003-12-10 12:20:52
下边的程序没能够获取,怎样才可以???

HANDLE hWindow;

// 取得 Program Manager 窗口句柄
hWindow = FindWindow(0,txtcaption->Text.c_str()) ;

// 查找 SHELLDLL_DefView 子窗口
if (hWindow)
{
hWindow = FindWindowEx(hWindow, 0, "Shell DocObject View", NULL);
// 查找 Internet Explorer_Server 孙子窗口 呵呵
if (hWindow)
if (FindWindowEx(hWindow, 0, "Internet Explorer_Server",""))
ShowMessage("aa");

}
...全文
245 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
ccrun.com 2003-12-11
  • 打赏
  • 举报
回复
HWND hIE = NULL;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
bool CALLBACK EnumChildWindowsProc(HWND hWin,LPARAM lParam)
{
//枚举窗体
char szBuffer[256];
GetClassName((void *)hWin, szBuffer, 255);
if(strcmp(szBuffer, "Internet Explorer_Server") == 0)
{
hIE = hWin;
return false;
}
EnumChildWindows(hWin, (WNDENUMPROC)EnumChildWindowsProc, 0);
return true;
}
void __fastcall TForm1::Button1Click(TObject *Sender)
{
hIE = NULL;
HWND hWin = (void *)0x000503D6; // 这里换成父窗体的句柄就可以了。
EnumChildWindows(hWin, (WNDENUMPROC)EnumChildWindowsProc, 0);
if(hIE != NULL)
ShowMessage("Found! Handle: " + String((int)hWin));
else
ShowMessage("Not Found!");
}
//---------------------------------------------------------------------------
ccrun.com 2003-12-11
  • 打赏
  • 举报
回复
用EnumChildWindows不是更好吗?
我给你整段代码去。
MEFULEU 2003-12-11
  • 打赏
  • 举报
回复
呵呵,我上边的函数功能应该是获得其它一个窗体里的所有控件的类名?
MEFULEU 2003-12-11
  • 打赏
  • 举报
回复
搞了大半天,我这各递归函数还是有问题,谁帮我搞搞:
//获得其它一个窗体里的所有控件的句柄?
void lishandle(HWND MainWnd,TStringList *lt)
{
HWND FirstChild,FirstChild1,tmph;

char classname[255];
memset(classname,'\0',sizeof(255));

if((FirstChild = GetWindow(MainWnd,GW_CHILD))!=0)//找第一个子窗体
while(FirstChild!=0){

if( GetClassName(FirstChild, classname, sizeof(classname)) > 0){
AnsiString temp = StrPas(classname);
lt->Add(temp);
}

tmph= FirstChild;

FirstChild=GetWindow(FirstChild,
GW_CHILD
);
{
if (FirstChild==NULL)
{
FirstChild=GetWindow(tmph,
GW_HWNDNEXT
);

lishandle(FirstChild,lt);
}
}

}
}
MEFULEU 2003-12-11
  • 打赏
  • 举报
回复
ccrun(老妖)(www.ccrun.com) 不愧是老革命的人,谢拉!
ccrun.com 2003-12-10
  • 打赏
  • 举报
回复
以上代码在Win2k中通过。需要开启活动桌面,否则桌面只是个ListView。
ccrun.com 2003-12-10
  • 打赏
  • 举报
回复
void __fastcall TForm1::Button1Click(TObject *Sender)
{
HANDLE hWindow;
// 取得 Program Manager 窗口句柄
hWindow = FindWindow("Progman", "Program Manager");
// 查找 SHELLDLL_DefView 子窗口
if (hWindow)
{
hWindow = FindWindowEx(hWindow, 0, "SHELLDLL_DefView", NULL);
// 查找 Internet Explorer_Server 孙子窗口 呵呵
if (hWindow)
if (FindWindowEx(hWindow, 0, "Internet Explorer_Server",""))
ShowMessage("aa");

}
}
aliker 2003-12-10
  • 打赏
  • 举报
回复
to ccrun(老妖)(www.ccrun.com)
怎样获得其它一个窗体里的所有控件的句柄?
yjy1001 2003-12-10
  • 打赏
  • 举报
回复
呵呵

孙子窗口的孩子,该怎么表示??? 曾孙子窗口?
ccrun.com 2003-12-10
  • 打赏
  • 举报
回复
枚举其子窗口,然后判断类名是否为"Internet Explorer_Server"就可以了。并不难。
MEFULEU 2003-12-10
  • 打赏
  • 举报
回复
sorry

我搞错了,Internet Explorer_Server不知是那个控件!

我还以为是CppWebBrowser1
MEFULEU 2003-12-10
  • 打赏
  • 举报
回复
to: ccrun(老妖)(www.ccrun.com)

我是想获取程序中的Internet Explorer_Server;

比如一个程序中使用了CppWebBrowser1

我想捕获它!

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧