通过指定窗口标题的子字符串来标识子窗口 [英] Identifying a child window by specifying the substring of window title

查看:104
本文介绍了通过指定窗口标题的子字符串来标识子窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好.

在识别子窗口时遇到问题,让我解释一下...这里的子窗口标题为"Liquidate Position:3692".此处子窗口中的每次引用ID都不同,例如:1)"Liquidate Position:3693"(2)"Liquidate Position:4521".因此,如果我想使用FindWindow()API标识子窗口,这将非常困难,因为每次窗口标题都会更改.通过使用EnumWindows提及子字符串来标识Child窗口很困难,我的代码如下所示:

Hello All..

Am facing a problem in identifying the child window, Let me explain this... Here child window title is "Liquidate Position : 3692". Here everytime in child window Reference ID will be different i.e.,For Eg: 1) "Liquidate Position :3693" (2)"Liquidate Position : 4521" . So, if I want to identify the child window using the FindWindow() API, it will be quite difficult because everytime window title changes. So tought of identifying the Child window by mentioning the substring using EnumWindows and my code looks like this:

BOOL CALLBACK FindWindowBySubstr(HWND hwnd, LPARAM substring)
{
    const DWORD TITLE_SIZE = 1024;
    TCHAR windowTitle[TITLE_SIZE];

    if (GetWindowText(hwnd, windowTitle, TITLE_SIZE))
    {
        if (_tcsstr(windowTitle, LPCTSTR(substring)) != NULL)
        {
	  BOOL b = ::IsWindowVisible(hwnd);
	  if( b)
          {
            AfxMessageBox(windowTitle,0,0);
            //Child window identified.... Do some stuff with that....
	  }
            return false;
        }
    }
    return true; // Need to continue enumerating windows
}





const TCHAR substring[] = TEXT("Liquidate");
EnumWindows(FindWindowBySubstr, (LPARAM)substring);



有了这个我的代码无论如何能够在这里找到子窗口,那就太好了!!!但是问题是..当跟踪代码



With this my code anyway am able to find the child window here, thats great !!! But the problem is.. while tracing the code

GetWindowText(hwnd, windowTitle, TITLE_SIZE)

时,它会找到诸如Start,CiceroUIWndFrame,JumpList,Task Switching,开始菜单,IDD_EIML_Dialog-Dialog之类的窗口,网络弹出等等.我认为它可以找到系统上的所有窗口.

但是我的应用程序完全是时间限制的应用程序,即使延迟1〜2秒也会给我带来麻烦.而且,此代码查找系统上所有的窗口.显然会消耗很多时间.
请任何人能建议/指导我找到它的最快方法..

谢谢大家..

It finds the windows like Start,CiceroUIWndFrame,JumpList,Task Switching,Start menu,IDD_EIML_Dialog-Dialog,Network Flyout and so on.. And i think it finds all the windows on my system.

But my application is completely time constraint application eventhough 1~2sec delay will create a problem for me. And moreover this code finds all the windows on the system & obviously it will consume lot of time.
Please can anyone suggest/guide me the fastest way to find it..

Thank you all..

推荐答案

如果您知道父窗口,请使用EnumChildWindows [
If you know the parent window, use EnumChildWindows[^] instead. It has the similar syntax, and uses the same callback function


这篇关于通过指定窗口标题的子字符串来标识子窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆