Which of the following sentences is acceptable?
(1) The girl stood by the window gazing at the twinkling stars.
(2) The girl gazing at the twinkling stars stood by the window.
(3) The little boy came toward me humming a song.
(4) The little boy humming a song came toward me.
(5) The candidate was sitting there, shocked by the result of the election.
(6) The candidate sitting there was shocked by the result of the election.
They're all OK, but mean different things. For example:
On the other side of the room I saw two little boys. The little boy [who was] humming a song came towards me.
(That is, in the second of each pair, the clause with the -ing form is defining.)