It can be done, but since HP make the case cabling, power supply in some models only to work with a specific motherboard peripherals a long and painful process.
Your better off, just building a new base unit and transfer stuff like drives, memory and cards across.
Oh almost forgot, your Windows licence will not be valid for the new equipment, nor will the recovery media work.