Quantum-state preparation and control via the Zeno effect