Question

I need some help about the win32 api and especially WindowsFromDc.

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.

But when I do a WindowsFromDC with the DC returned by the DrawTextEx function, i got a null return.

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 ?

Thank you.

Ps : Sorry for my bad english...

Was it helpful?

Solution

Device context handles are not valid when passed cross-process. So what you are attempting to do is not possible.

As for your other questions:

Is it possible to have an HDC that is not associated with an HWND?

Yes that is perfectly possible. Plenty of device contexts are not associated with windows.

How I can get the HWND of the window which call DrawTextEx?

Windows do not call functions, code calls functions. So, the question does not really mean anything.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top