loop until FindWindow(TEXT("Crossfire"), NULL); returns something
works fine here /
also here is a bad alternation that may work with any window, regardless of its name
Code:
BOOL WINAPI EnumProc(HWND hWnd, LPARAM lParam)
{
DWORD PID;
GetWindowThreadProcessId(hWnd, &PID); //check window process
if (PID == GetCurrentProcessId())
{
RECT rect;
GetWindowRect(hWnd, &rect);
if ((rect.right-rect.left > 50) && (rect.bottom-rect.top > 50)) //check window size
{
*(HWND*)(lParam) = hWnd;
return FALSE;
}
}
return TRUE;
}
HANDLE hWnd = NULL;
while (!hParent)
{
EnumWindows(EnumProc, (LPARAM)&hWnd);
Sleep(100);
}