[英]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
Folks, I apologize if this sounds like a newbie questions, but I am not very familiar with Windows development as a whole. 伙计们,对于这听起来像是一个新手问题,我深表歉意,但我对Windows开发整体并不十分熟悉。 So I was given App A, which does a lot of things and one particular function is to render a duck picture.
因此,我得到了App A,它可以完成很多事情,其中一个特殊功能是渲染鸭子图像。 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.
它在内部创建了一个标题为“ DrawingBoard”的窗口,稍后在程序准备渲染时,它将尝试找到该“ DrawingBoard”窗口。 I was only told that this is how App A finds the window to render the duck:
仅告诉我这是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);
}
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. 现在,我需要创建App B,并且要在App B上创建自己的“ DrawingBoard”窗口。由于App A使用上述算法来查找渲染窗口,而不是使用它自己的App A“ DrawingBoard”窗口,因此它将使用我的应用程序B“绘图板”窗口。
Questions: 问题:
1) Is this within the realm of possibility at all ? 1)这完全在可能性范围内吗? 2) Say if both App A & B have two windows with the same title "DrawingBoard".
2)说两个App A和B是否都有两个标题相同的窗口“ 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.
FindWindowEx(NULL,NULL,NULL,“” DrawingBoard“)哪个返回; 3)如果FindWindowEx总是返回App A” DrawingBoard“窗口的句柄,我该如何对其进行破解,使其返回App B” DrawingBoard“窗口。
Thanks for the help folks. 谢谢大家的帮助。
Say if both App A & B have two windows with the same title
"DrawingBoard"
.假设两个App A和B都有两个标题相同的窗口
"DrawingBoard"
。 Which one doesFindWindowEx(NULL, NULL, NULL, ""DrawingBoard")
return?FindWindowEx(NULL, NULL, NULL, ""DrawingBoard")
返回哪一个?
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.
如果FindWindowEx始终返回应用程序A“ DrawingBoard”窗口的句柄。 How do I hack it so it will return App B "DrawingBoard" window.
我该如何破解它,以便它返回App B“ DrawingBoard”窗口。
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.
那是前进的理智之路。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.