This thinking has been revised.
Here is a summary of the major points:
1. Birds developed in a lineage which extends from the Pterosauria, through primitive flying birds (eg. Enantiornithes, Dromaeosaurids etc) to modern flying birds and modern flightless birds.
2. The first active fliers were the primitive pterosaurs, called the Rhamphorhynchoidea. They existed from the late Triassic to the late Jurassic.
"Rhamphorhynchus "beak snout", is a genus of long-tailed pterosaurs in the Jurassic period. Less specialized than contemporary, short-tailed pterodactyloid pterosaurs such as Pterodactylus, it had a long tail, stiffened with ligaments, which ended in a characteristic diamond-shaped vane."
"This suborder is paraphyletic in relation to the Pterodactyloidea, which arose from within the Rhamphorhynchoidea, not from a more distant common ancestor."
3. Some Rhamphorhynchoidea developed into the Pterodactyloidea. They existed from the middle Jurassic to the late Cretaceous.
"Pterodactyloidea (meaning "winged finger", "wing-finger" or "finger-wing") forms one of the two suborders of pterosaurs ("wing lizards"), and contains the most derived members of this group of flying reptiles. They appeared during the middle Jurassic Period, and differ from the basal rhamphorhynchoidea by their short tails and long wing metacarpals (hand bones). The most advanced forms also lack teeth."
4. Some Pterodactyloidea developed into primitive, flying birds (eg. Dromaeosauridae, Enantiornithes etc) beginning in the middle to late Jurassic.
5a. Some primitive flying birds developed into modern flying birds (eg. Neognathae) by the late Cretaceous.
5b. But some primitive flying birds settled on the land and became primitive, secondarily flightless birds (eg. Ornithomimosauria, etc) in the early Cretaceous
then those primitive, flightless birds developed into modern Ratites (ostrich, emu etc) in the late Cretaceous.
6. Dinosaurs developed in their own separate line from the late Triassic to the late Cretaceous. The dinosaur line went extinct at the end of the Cretaceous.
Also it is possible that within a particular bird group, there could be both original flying birds and secondarily flightless birds. For example there may have been flying Dromaeosauridae AND flightless Dromaeosauridae.