如何在App B中创建一个窗口,以便App A可以使用它来渲染而不是使用它自己的Window(How do I create a Window in App B so that App A may u

编程入门 行业动态 更新时间:2024-10-27 08:30:48
如何在App B中创建一个窗口,以便App A可以使用它来渲染而不是使用它自己的Window(How do I create a Window in App B so that App A may use it to render instead of using it's own Window)

伙计们,如果这听起来像是一个新手问题,我很抱歉,但我对整个Windows开发并不十分熟悉。 所以我给了App A,它做了很多事情,一个特殊的功能是渲染鸭子图片。 在内部,它创建了标题为“DrawingBoard”的Window,稍后当程序准备好渲染时,它将尝试找到这个“DrawingBoard”窗口。 我只被告知这是App A找到渲染鸭子的窗口的方式:

static const TCHAR TITLE_NAME[] = "DrawingBoardParent"; static const TCHAR TITLE_CLASS_NAME[] = "DrawingBoard"; HWND parent = FindWindowExA(NULL, NULL, NULL, TITLE_NAME); while (parent != NULL) { //find the child window by window title window = findWindowRecursive(parent, TITLE_CLASS_NAME); if (window != NULL) { break; } //no child by the given title name found, go down one level parent = FindWindowExA(NULL, parent, NULL, TITLE_NAME); }

现在我需要创建App B,我想在App B上创建自己的“DrawingBoard”窗口。因为App A使用上面的算法来查找渲染窗口,而不是使用它自己的App A“DrawingBoard”窗口,它将使用我的App B“DrawingBoard”窗口。

问题:

1)这是否属于可能性范围? 2)假设App A和B都有两个具有相同标题“DrawingBoard”的窗口。 哪一个FindWindowEx(NULL,NULL,NULL,“”DrawingBoard“);返回?3)如果FindWindowEx总是返回App A”DrawingBoard“窗口的句柄。如何破解它以便它将返回App B”DrawingBoard“窗口。

谢谢你们的帮助。

Folks, I apologize if this sounds like a newbie questions, but I am not very familiar with Windows development as a whole. So I was given App A, which does a lot of things and one particular function is to render a duck picture. Internally it created the Window with the title 'DrawingBoard' and later on when the program is ready to render it will try to find this "DrawingBoard" window. I was only told that this is how App A finds the window to render the duck:

static const TCHAR TITLE_NAME[] = "DrawingBoardParent"; static const TCHAR TITLE_CLASS_NAME[] = "DrawingBoard"; HWND parent = FindWindowExA(NULL, NULL, NULL, TITLE_NAME); while (parent != NULL) { //find the child window by window title window = findWindowRecursive(parent, TITLE_CLASS_NAME); if (window != NULL) { break; } //no child by the given title name found, go down one level parent = FindWindowExA(NULL, parent, NULL, TITLE_NAME); }

Now I need to create App B and I want to create my own "DrawingBoard" window on App B. Because App A uses the above algorithm to find the rendering window, instead of using it's own App A "DrawingBoard" Window, it will use my App B "DrawingBoard" Window.

Questions:

1) Is this within the realm of possibility at all ? 2) Say if both App A & B have two windows with the same title "DrawingBoard". Which one does FindWindowEx(NULL, NULL, NULL, ""DrawingBoard"); return ? 3) If FindWindowEx always returns the handle for App A "DrawingBoard" window. How do I hack it so it will return App B "DrawingBoard" window.

Thanks for the help folks.

最满意答案

假设App A和B都有两个具有相同标题"DrawingBoard"窗口。 哪一个FindWindowEx(NULL, NULL, NULL, ""DrawingBoard")返回?

这是不明确的。 它将返回其中一个。 您无法影响返回的内容。

如果FindWindowEx总是返回App A“DrawingBoard”窗口的句柄。 我如何破解它以便它将返回App B“DrawingBoard”窗口。

你不能。 另一个应用程序坏了。 它搜索它创建的窗口是破坏的,因为它可以产生错误的窗口,一个来自另一个进程的窗口。

您可以通过为窗口使用不同的名称来避免被此应用程序捕获。 但是你真的应该修复或删除有缺陷的程序。 这是理智的前进方向。

Say if both App A & B have two windows with the same title "DrawingBoard". Which one does FindWindowEx(NULL, NULL, NULL, ""DrawingBoard") return?

That is ill-defined. It will return one of them. You cannot influence which is returned.

If FindWindowEx always returns the handle for App A "DrawingBoard" window. How do I hack it so it will return App B "DrawingBoard" window.

You cannot. The other app is broken. Its search for a window that it created is broken, since it can yield the wrong window, a window from another process.

You can avoid getting caught out by this app by using a different name for your window. However you really ought to either fix or remove the defective program. That's the sane way forward.

更多推荐

本文发布于:2023-08-05 19:59:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1439377.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:自己的   可以使用   创建一个   它来   而不是

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!