Is it possible to make a cylinder like the picture with straight lines for the square.
When I use subsurf the square on top is getting to round without subsurf the cylinder is not nice and round
It is not a circle but a cylinder.
Yes.
http://wiki.blender.org/index.php/Manual/Subsurf_Modifier#Weighted_creases_for_subdivision_surfaces
Select all the edges you want to keep sharp, then set their crease value to 1.
You could add an Edge Split Modifier.
The marked edges have been Marked Sharp (CTRL+E) and Creased to 1.00(SHIFT+E).
Or you could increase the edge angle until you get the desired look.
Here is the Wiki page - sorry about the highlights, blender.org seems to be unavailable, so this is the cached page.
Thanks Ctrl+E worked for me.