가이 작업을 수행 할 좋은 방법이 있습니다,하지만 당신을 위해 작동 할 수 있습니다 하나의 접근 방식에 오버레이를 그리는 GetMsgProc을 추가 할 SetWindowsHookEx (...)를 사용하여 문제의 응용 프로그램을 후크하는 것입니다 WM_PAINT 메시지에 대한 응답. 기본 아이디어는 응용 프로그램이 자체 드로잉을 마친 직후에 그래픽을 그리는 것입니다. 주요 응용 프로그램에서
:
....
HMODULE hDllInstance = LoadLibrary("myFavoriteDll");
HOOKPROC pOverlayHook = (HOOKPROC)GetProcAddress(hDllInstance, "OverlayHook");
SetWindowsHookEx(WH_GETMESSAGE, pOverlayHook, hDllInstance, threadId);
어딘가에 DLL에서 꺼짐 :
LRESULT CALLBACK OverlayHook(int code, WPARAM wParam, LPARAM lParam)
{
//Try and be the LAST responder to WM_PAINT messages;
//Of course, if some other application tries this all bets are off
LRESULT retCode = CallNextHookEx(NULL, code, wParam, lParam);
//Per GetMsgProc documentation, don't do anything fancy
if(code < 0) return retCode;
//Assumes that target application only draws when WM_PAINT message is
//removed from input queue.
if(wParam == PM_NOREMOVE) return retCode;
MSG* message = (MSG*)lParam;
//Ignore everything that isn't a paint request
if(message->message != WM_PAINT) return retCode;
PAINTSTRUCT psPaint;
BeginPaint(message->hwnd, &psPaint);
//Draw your overlay here
...
EndPaint(message->hwnd, &psPaint);
return retCode;
}
당신의 C# 코드는/페이지 수 무겁고 상응 매우 추한 호출합니다 있도록이 모두는 Win32이다. DLL을 관리하지 않아야합니다 (자신이 아닌 다른 프로세스에 인젝션하려는 경우).
이렇게하면 창 자체에 렌더링 할 때 z 순서 및 자르기 문제로 인한 문제가 해결됩니다. 그러나, 대상 응용 프로그램이 WM_PAINT에 응답하는 WinProc 외부의 드로잉을 수행하는 경우, 이것은 전적으로 드문 경우는 아닙니다.
당신이 원하는 무엇인지에 구체적 할 수 다이렉트 X의 상단에 그릴 할 수 있습니다? 텍스트를 다른 응용 프로그램의 윈도우에 놓고 거기에 머무르게하는 우아한 방법은 없습니다. 단지 추악한 방법입니다. 그러나 특정 상황에 따라 다른 방법으로 원하는 것을 얻을 수 있습니다. –
내가하고 싶은 것을 보여주기 위해 이미지가 추가되었습니다. – s5804