We are asked this sort of question quite a lot, and I think the best advice is to get what you think you will be most comfortable with in the longer term. There are very few bad cameras these days.
Remember that the camera is only the start - lenses and accessories can easily add up to several times the price of the camera itself. You're buying into a system, and once you have a collection of lenses etc it is expensive to swap to a different manufacturer.
Both the 400D and D40x are good cameras, although (tell me if I'm wrong here) there are some restrictions on the lenses that the D40 will accept. Personally I went the Canon route and have no regrets, but if I were starting again I would have to think long and hard.
For now, go to your friendly local store and handle both cameras - see which feels better to you. Whichever you choose, I don't think you'll be disappointed.