In his book Flow: The Classic Work on How to Achieve Happiness Mihaly Csikszentmihalyi answers this question by saying that happiness is not something that happens to us, nor is it the result of good fortune or random chance, nor does it depend on outside events: what it does depend on is how we interpret those outside events. What he noticed was that those experiences that people describe as being their happiest are those timeless moments when we are completely absorbed in what we are doing and when our performance is effortless and extraordinary - a state which he calls "Flow". What makes this book so exciting is its thesis that we can create the conditions of flow.
Put simply: if we can find or create situations where we feel that our skills are adequate to cope with the challenges at hand; where we have clear goals and feedback about how well we are achieving these goals; and where our concentration is so intense that there is no attention left over to think about anything else, or to worry about problems, then we are likely to experience flow. And then we will feel happy.