Poincaré-Pontryagin-Melnikov functions for a class of perturbed planar Hamiltonian equations