Kindly explain the meaning of this sentence from Harry Potter and the Deathly Hallows

He had one, brief glimpse of the stone Pensieve on the desk where he had left it, and then an earsplitting noise made him cry out, thinking of curses and returning Death Eaters and the rebirth of Voldemort —

But it was applause. All around the walls, the headmasters and headmistresses of Hogwarts were giving him a standing ovation; they waved their hats and in some cases their wigs, they reached through their frames to grip each other’s hands; they danced up and down on the chairs in which they had been painted; Dilys Derwent sobbed unashamedly; Dexter Fortescue was waving his ear-trumpet; and Phineas Nigellus called, in his high, reedy voice, “And let it be noted that Slytherin House played its part! Let our contribution not be forgotten!”

I didn't understand the sentence in bold, from the para given above. Grasped each other's hands? Danced on their chair? What did they do, what action was performed over there? Kindly explain.

Thanks in advance.


The "headmasters and headmistresses of Hogwarts" refered to are magically animated portrait paintings hanging on the walls. These paintings have frames so in order to shake hands with each other (in different paintings) they need to reach through these frames. In many cases, the headmasters/headmistresses were "painted" sitting down on chairs (since they were formal portraits). It's these chairs that they are dancing up and down on in their excitement.