WindowsFromDc返回null [英] WindowsFromDc return null
问题描述
我需要有关win32 api的帮助,尤其是WindowsFromDc.
I need some help about the win32 api and especially WindowsFromDc.
我有一个可以挂接到另一个应用程序的应用程序.这两个应用程序通过NamedPipe进行通信.在第二个应用程序中,我已钩住DrawTextExW函数,并从该函数获得了HDC.
I have a application which hook a another application. This two application communicate by a NamedPipe. In the second application, I have hook the DrawTextExW function and I get a HDC from this function.
但是当我使用DrawTextEx函数返回的DC执行WindowsFromDC时,我得到了空返回.
But when I do a WindowsFromDC with the DC returned by the DrawTextEx function, i got a null return.
因此,我对此有一些疑问: -HDC可能没有HDWN吗? -如何获取调用DrawTextEx的窗口的HWND?还有其他方法吗?
So, I have some question about that : -Is it possible a HDC don't have a HDWN with ? -How I can get the HWND of the window which call DrawTextEx ? There are other way do to that ?
谢谢.
Ps:对不起,我的英语不好...
Ps : Sorry for my bad english...
推荐答案
在跨进程传递时,设备上下文句柄无效.因此,您尝试做的事情是不可能的.
Device context handles are not valid when passed cross-process. So what you are attempting to do is not possible.
关于您的其他问题:
是否有可能没有与
HWND
关联的HDC
?
是的,这完全有可能.大量的设备上下文与Windows无关.
Yes that is perfectly possible. Plenty of device contexts are not associated with windows.
如何获取调用DrawTextEx的窗口的
HWND
?
Windows不调用函数,而代码调用函数.因此,这个问题实际上没有任何意义.
Windows do not call functions, code calls functions. So, the question does not really mean anything.
这篇关于WindowsFromDc返回null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!