When looking for students to work on a research project: contact good students directly or contact all class then select the good ones?
At my institution the selection was two-fold. The professor usually has an open invitation for all students to apply for their lab, but chosen students were known to be approached to raise their interest. This was always done carefully as to don't imply any precedence between students, but not secretly, and almost always orally (not by email or similar). For example, at the project oral defense, the instructor would suggest to the best students to consider applying for their lab.

At least all of my instructors were careful not to "flatter" the students, but only to raise their interest. There is little sense to have a, no matter how brilliant, student working on a project, if they are not interested in the subject.