There are many ways to achieve the state of being thankful and grateful to God as well as to His Creatures.
The first among them is that you realize the reason to be thankful for. Whether you realize your blessings that come in various forms from God or you acknowledge the favors that others might do for you now and then.
Once you realize that there is something to be thankful for in your life you have crossed the first level.
The second level is to actually say 'thanks' to the one whom you think is responsible for the good that happened to you or the bad that didn't happen! Obviously, it is all from the Creator and sometimes He makes His Creatures a way to bring good to others. So, here, first we need to thank the One Who gave you all that you asked for and more, kept you safe, helped you out, was a force behind you to stay strong although apparently you could see no change in your problems etc, but despite of all the odds Who kept you there, firm and unwavering.
Thank the One Who is the source of all blessings and strength.
Secondly, you need to thank the persons that always stayed by your side, loved you unconditionally or did any favor for you by any means. You actually need to thank them with nice words and gestures.
The third level in achieving the state of being thankful is actually spending out of whatever you are capable of in helping out those in need. You might think that you are at present in most need but still you might find someone whose problem is worse than yours; who is homeless, hungry and ill. Whatever way you can spend whatever little you have in the way of The Creator for helping the needy you must spend. This will not decrease you in wealth rather it will open new doors of blessings upon you from the Lord of the Worlds.
The last but the most important thing to do yet the most difficult for most among us is 'not to complain'.
Most of us keep our focus fixed on 'what we don't have', 'what is missing', 'what bad happened with us', and 'what we badly need'. It is quite natural to feel the discrepancies in life but it is not impossible to try and engage ourselves in something so that we can disengage ourselves from constantly getting reminded of only the 'deprivations' in our life. Keeping busy in doing those things that bring joy, contentment and feeling of worth in us is extremely important to get out of the gloom.
Not complaining about the things we don't have and remembering the things that we do have make a big difference in our mindset. We might be really creative, useful, beneficial to others, constructive, helpful and positive by nature but the odds in life just fog those sparks in our personality. We need to clear this fog. The sparks are still there. Let them shine, and ignite your talents, your creativity and worth by working on them. Keep busy in doing things that you like to do. Do something which can benefit others. Use your talents. When we begin to shine the life of others the rays keep reflecting on us too. We bring about a brightness that engulfs our dull and gloomy life and enlightens it too!!
Be thankful to the Almighty, be thankful to others and keep busy.
These are the ways we can achieve thankfulness and get rid of a sad state of mind, by the Will of Almighty Allah.
PS: These thoughts are actually learnt and understood from a lecture of my teacher.