Please help with creating a Hidden Window inside a Win32 DLL, thank you.
-
Hi there, Please help me, I have been so frustrated. I am working on a Win32 DLL. Inside the dll, I am trying to create a popup window which is hidden and covers the entire desktop so I can process mouse message across the screen and do rubber banding. I am doing this because of the restriction of SetCapture(HWND hwnd) API. What I can do now is that as soon as the client loads the DLL, a hidden window will be created and mouse messages will be processed in GrabProc Callback function. Instead of creating the hidden window when the dll is first loaded, I am hoping to create a hidden window when the mouse is down and destroy it when the mouse it up. I am a newbie on Windows Programming. Would someone please give me some pointers and show me how to accomplish what I need. Thank you very much for your help. BOOL APIENTRY DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) { if (dwReason == DLL_PROCESS_ATTACH) { CreateHiddenWindow(); } } BOOL CreateHiddenWindow() { static TCHAR szAppName[] = TEXT ("Test") ; HWND hwnd ; MSG msg ; WNDCLASS wndclass ; wndclass.style = CS_HREDRAW | CS_VREDRAW ; wndclass.lpfnWndProc = GrabProc ; wndclass.cbClsExtra = 0 ; wndclass.cbWndExtra = 0 ; wndclass.hInstance = g_hInstance ; wndclass.hIcon = NULL; wndclass.hCursor = LoadCursor (NULL, IDC_ARROW); wndclass.hbrBackground = NULL; wndclass.lpszMenuName = NULL; wndclass.lpszClassName = szAppName ; if (!RegisterClass (&wndclass)) { MessageBox (NULL, TEXT ("This program requires Windows NT!"), szAppName, MB_ICONERROR) ; return 0 ; } hwnd = CreateWindowEx(WS_EX_TRANSPARENT, szAppName, NULL, WS_POPUP, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), NULL, NULL, g_hInstance, NULL); ShowWindow(hwnd, SW_SHOW); UpdateWindow (hwnd) ; while (GetMessage (&msg, NULL, 0, 0)) { TranslateMessage (&msg) ; DispatchMessage (&msg) ; } return msg.wParam ; } LRESULT CALLBACK GrabProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { // Handle mouse down, move, up messages for entire screen // rubber banding sw