He became King of Hanover on 28 June 1837 on the death of his brother William IV of the United Kingdom . On 20 June 1837 , King William died , and Princess Victoria became Queen of the United Kingdom . Ernest became the King of Hanover .