A direct-forcing immersed boundary method (DFIB) with both virtual force and heat source is developed here to solve Navier-Stokes and the associated energy transport equations to study some thermal flow problems caused by a moving rigid solid object within. The key point of this novel numerical method is that the solid object, stationary or moving, is first treated as fluid governed by Navier-Stokes equations for velocity and pressure, and by energy transport equation for temperature in every time step. An additional virtual force term is then introduced on the right hand side of momentum equations in the solid object region to make it act exactly as if it were a solid rigid body immersed in the fluid. Likewise, an additional virtual heat source term is applied to the right hand side of energy equation at the solid object region to maintain the solid object at the prescribed temperature all the time. The current method was validated by some benchmark forced and natural convection problems such as a uniform flow past a heated circular cylinder, and a heated circular cylinder inside a square enclosure. We further demonstrated this method by studying a mixed convection problem involving a heated circular cylinder moving inside a square enclosure. Our current method avoids the otherwise requested dynamic grid generation in traditional method and shows great efficiency in the computation of thermal and flow fields caused by fluid-structure interaction.