for these 3 cameras,
no doubt about it, if you are looking for VALUE FOR MONEY, k10d is the way to go
that said, you might not necessarily like it. do take note that every brand has its pros and cons. the prices you are being quoted seems a bit on the high side as well.
k10d
-only one out of your three choices that has in-body image stabilisation, the IS is solid too
-can be considered a level-up on the dslr food chain, compared to 400d and d40x to be honest, has a lot more advanced functions if you wish to have room to grow
-i would bravely say that handling is top-class, not sure about d40x but definitely better than canon 400d for most people
-pentax lenses across the board are good quality
-has problems with yellowish cast for indoor shots, but nothing that shooting in raw or setting custom wb cannot solve
-pentax lenses are hard to find in singapore
-great low light performance (i.e. relatively clean higher iso @ 400 and 800)
some points you would have to note about 400d, which is also an excellent cam, would be that you should try holding the camera.. what most reviewers have said about the canon entry level dslrs is that they are way too small. which is great for ladies and guys with smaller sized hands, but not everyone is that. also, consumer grade lenses are affordable, but build and optical quality is often.. not as good. if you wish to make large large prints you might have to go for l lens? :dunno:
for d40x, i would wager that most people would not encourage you to buy it, unless you are willing to pay more in the long term should you wish to obtain more lenses.. the d40x has no built-in autofocus motor.. so you have a limited selection of lenses to choose from. that said, there have been numerous, numerous discussions on this since the day clubsnap was born. ok, just kidding, but do a search, i'm sure you will turn up quite significant amount of threads on stuff like this.