开发者

How find a SubForm of a application with changing texts?

开发者 https://www.devze.com 2022-12-23 02:41 出处:网络
I have Application X with Su开发者_运维知识库bform x1, x2, x3. The Subform has, because its multi-language, not a static text in it, neither a specific window header text or something.

I have Application X with Su开发者_运维知识库bform x1, x2, x3.

The Subform has, because its multi-language, not a static text in it, neither a specific window header text or something.

What can I do to find this window in my code an react when its open, e.g. with a messagebox?


You could use it's name to find it.

F.e.

    public bool FindWindow(string windowName)
    {
        foreach (Form childWindow in this.MDIChildren)
        {
            if (childWindow.Name == windowName)
                return true;
        }

        return false;
    }


If the window you're looking for is in another application, you have to find out its window name (or window class). You can use Spy++ for this, which is installed with Visual Studio and/or the Windows SDK (not sure). You can also try UISpy, which uses Windows UI Automation and is also installed with one of them. Once you know the name, you can use the Win32 API function FindWindow(Ex) to find the window, or use Windows UI Automation (from the System.Windows.Automation namespace).


I'm not sure creating several forms for localization is a good thing. Do you know about Localization?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号