The troubleshooting section for your system is here:
http://h20000.www2.hp.com/bizsupport/TechSupport/SupportTaskIndex.jsp?lang=en&cc=us&prodTypeId=321957&prodSeriesId=1839143&taskId=110 The number of light flashes will narrow the defect to a section, for example, 4 flashes is video.
Software problems can be varied and multiple.
The hardware parts easiest for an individual to fix are RAM, Battery and Hard-drive. If you have a small screwdriver, and are willing, you may solve a hardware problem through elimination.
1.) Hard reset: Unplug the AC, remove the battery, press the power button for about 45 seconds to drain any residual charge. leave out the battery, plug in the AC and attempt to start. Make note of any error messages or differences. If the battery were shorted, this would solve the problem.
[If you have an internet connection , and another working PC, videos for repairing your HP model are available here]
http://h20464.www2.hp.com/resultsCSR.htm?prodSeriesId=1839143&MEID=D20132AC-5C2B-424F-93E0-91812FB944722.) if the problem persists: With the battery removed and the AC disconnected: Remove the RAM cover. Carefully remove the first RAM chip, set aside. Plug in AC and see if the system is okay now. If not, turn off and unplug, remove other RAM module, and replace with the first. Start.
This may have reduced your problem to a RAM module.
If not, and the system still is not showing the setup screen: try the hard-drive.
3.) With battery removed and AV disconnected: Using small screwdriver, remove the small screw(s)s holding the hard-drive cover (the cover will have an icon showing multiple stacked disks). with the cover removed, the hard-drive will be fastened with 2 or 3 screws, depending on model. Carefully pull out the HD and place in a safe location. With the AC reconnected, power the system and note any differences. Are you consistently getting the startup screen? Can you enter Setup?
Your problem description suggests the startup has been erratic and unpredictable. This is often power or memory. If you can consistently get past the startup screen, but it hangs when loading the operating system, this is likely a problem with the HD or the software setup. If you have a spare laptop HD, you can swap and install your bare operating system on this HD to eliminate the HD and Operating System as the problem.
If your Compaq as is it was from the factory, it has a restore partition to restore the operating system to the factory setup. If you can get the system started, you can restore individual parts of your system. otherwise, you may have to do a complete restore (F11 on Startup).
Troubleshooting is a logical process of elimination, looking for the simplest (and hopefully least expensive) solution first.
I have repaired many HP and Compaq systems. The HP site is very helpful with troubleshooting suggestions and even videos. If you have the patience, a few tools, another working PC and an Internet connection, you can solve 95% of PC problems.
Good luck. If you find this helpful, please accept this as a solution.