Obtaining Application Window Handle from .dll?

Started by
0 comments, last by nuclear123 12 years, 3 months ago
Does anyone know of a method where my dll, that is injected at runtime, can obtain the applications main window handle? thanks
Advertisement
I think i found it it was FindWindow(). But i still have one problem. Basically im trying to create a transparent window. Then with this transparent window i want to have it lay overtop of another specified window. For some reason this isnt working all to well. If seems as if when i execute the following code, Minesweeper becomes partially transparent and i can see thru it like a fuzzy haze. All i want to do is create a clear see thru window and have it stay embedded into the client area of minesweeper. I dont want to make minesweeper see thru! just my window i create

http://imageshack.us/photo/my-images/94/q9akqu.png/

WNDCLASS wc;
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = MainWndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = m_hInstance;
wc.hIcon = LoadIcon(0, IDI_APPLICATION);
wc.hCursor = LoadCursor(0, IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetStockObject(NULL_BRUSH);
wc.lpszMenuName = 0;
wc.lpszClassName = L"D3DWndClassName";
RegisterClass(&wc);

HWND m_hwndOverlay = CreateWindowEx(WS_EX_TOPMOST | WS_EX_COMPOSITED | WS_EX_TRANSPARENT | WS_EX_LAYERED, // dwExStyle
wc.lpszClassName, // lpClassName
L"hi", // lpWindowName
WS_OVERLAPPED, // dwStyle
CW_USEDEFAULT, CW_USEDEFAULT, // x, y
500, 500, // nWidth, nHeight
NULL, // hWndParent
NULL, // hMenu
m_hInstance, // hInstance
this); // lpParam

MARGINS dwmMargins = {-1, -1, -1, -1};

// Extend glass to cover whole window
DwmExtendFrameIntoClientArea(FindWindow( 0, L"Minesweeper" ), &dwmMargins);

// Show the window
ShowWindow(m_hwndOverlay, SW_SHOWDEFAULT);
UpdateWindow(m_hwndOverlay);

This topic is closed to new replies.

Advertisement