Considering adverse selection with a continuum of types, a general characterization of implementability in terms of h-convexity is provided. This enables to write the principal's program as a variational problem with h-convexity constraint for which existence of a solution is proved. The class of models considered here is large since the dimension of the parameter may differ from that of the contract and no structural assumption of single-crossing type is required. In particular calculus of variations problems for which admissible functions are convex ones or convex solutions to multi-time Hamilton-Jacobi equations are particular cases of the problems studied below.