This thread should help explain everything:
http://forum.thegamecreators.com/?m=forum_view&t=55616&b=18
and feel free to use the attached zip file as a template(it has a codeblocks file)
if you get tons of undefined references or non existent include files then you may not have the directx sdk installed
to install it: download the directx sdk from microsoft(search for it) and install it where ever
then once you got the directx sdk all setup goto codeblocks and then goto compiler options(or if you just want it for 1 project, goto the projects build options) then goto directories and under the tab of compiler, goto add and then type "<path to directx sdk>include" and then press ok and then goto the tab for linker, type "<path to directx sdk>libx86" and then at the bottom press ok which will save the compiler options and stuff and then your ready to go!
edit:
this is all assuming your using mingw which is the default compiler for codeblocks, if your using a different compiler than this may vary a bit