User Interfaces and viewports

I’ve been wondering how people make user interfaces and HUDs in a program.
With a HUD or userinterface I mean a 2D “view window” through which the user looks which is basically placed upon the 3D view.

For example, your GUI is the framework of a window, with buttons etc etc in it, and in the centre of the screen is the window through which the 3D world is displayed.

Any ideas/linkage?