What I don't quite understand is how Cameron immediately can claim the office of PM if there is a hung parliament. It seems getting things a bit backwards to first become PM and only then start negotiating with parliament about confidence. At least that's what I distill from 'angry Tories' about 'Brown clinging to power after losing the elections'.

I wouldn't know how else you could have a transfer of power in an orderly way without returning to some archaic state where you don't have a government beyond the monarch.

Like this

1. hung parliament
2. parties decide to form a coalition or express their consent to a minority government
3. Brown resigns (unless of course it's Lab-Lib)
4. Queen appoints new PM on Brown's resignation.