Use GetForegroundWindow() rather than GetDesktopWindow() for dialog functions on Windows