简体   繁体   English

如何在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

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 does FindWindowEx(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.

相关问题 如何在空的Visual C ++项目(或控制台应用程序)中使用查找窗口和sendmessage - how do I use find window and sendmessage in empty visual c++ project (or console app) 如何使用Win32 API在Windows的桌面窗口层次结构中的特定位置放置我的应用程序窗口? - How do I place my app window in a certain position in the desktop window hierarchy on Windows using win32 api? 我可以为Window Universal App创建一个警报应用程序吗? - Can I create an alarm app for Window Universal App? 如何使用c ++和opengl在Mac中创建窗口? - How do I create a window in mac using c++ and opengl? 如何使用 url 在后台使用应用程序的主 window 启动 UWP 应用程序 - How to launch UWP app with app's main window in background using url 如何在MFC中创建预渲染输入窗口? - How can I create a pre-render input window in MFC? 如何创建居中的 GLFW window? - How do I create a centered GLFW window? 如何将win32窗口渲染为opengl纹理? - How do I render a win32 window to an opengl texture? 我可以使用SetWindowPos将窗口放在另一个窗口后面,但是如何将它放在给定窗口的前面呢? - I can use SetWindowPos to place the window behind another window, but how do I place it in front of a given window? 如何在基于NON-MFC的应用程序中创建新的窗口/对话框 - how to create new window / dialog in NON-MFC based app
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM