TGCapture: moved duplicate code to its own class which is now a superclass of all the TGxxx classes.