26 return GetCurrentProcessId();
32 HANDLE pH = OpenProcess(SYNCHRONIZE,
false, (DWORD)pid);
35 DWORD retValue = WaitForSingleObject(pH, 0);
37 return retValue == WAIT_TIMEOUT;
44 BOOL CALLBACK
findFunc(HWND hWnd, LPARAM lParam)
47 TCHAR* pTail = (TCHAR*)lParam;
49 GetWindowText(hWnd, Title,
NUMELMS(Title));
51 if(strlen(Title) < strlen(pTail))
53 TCHAR* pTitle = Title + strlen(Title) - strlen(pTail);
56 int32_t len = min((int32_t)strlen(pTitle), (int32_t)strlen(pTail));
57 if(!_strnicmp(pTitle, pTail, len))
70 const char* pName = pWindow;
81 hWindow = FindWindow(
NULL, pWindow);
82 bFound = hWindow ?
true :
false;
87 bFound = !EnumWindows(
findFunc, (LPARAM)pName);
99 HWND hWnd = (HWND)handle;
106 DWORD oldThread = GetWindowThreadProcessId(hWnd, &pid);
110 DWORD currentThread = GetCurrentThreadId();
113 wp.length =
sizeof(WINDOWPLACEMENT);
114 GetWindowPlacement(hWnd, &wp);
116 if(SW_MINIMIZE == wp.showCmd || SW_SHOWMINIMIZED == wp.showCmd)
117 ShowWindow(hWnd, SW_RESTORE);
120 AttachThreadInput(oldThread, currentThread, TRUE);
121 SetActiveWindow(hWnd);
122 SetForegroundWindow(hWnd);
123 BringWindowToTop(hWnd);
125 AttachThreadInput(oldThread, currentThread, FALSE);
128 GetClientRect(hWnd, &r);
129 InvalidateRect(hWnd, &r,
true);