2) I want the snake to move within a grid, say 24x24 or 32x32. But the snake in the code moves/turns accordingly to my controls
The code I wrote does make it follow a grid. You changed the drawing code from:
DrawImage body(Snake\snaketype), Snake\xpos * 32, Snake\ypos * 32to
DrawImage snakebody(Snake\snaketype), Snake\xpos +16, Snake\ypos +16Notice that I was mulitplying the x & y values by 32. This was to make the snake align to a 20x15 grid of 32x32 squares. The snake moves in exact increments (gridsquare1 to gridsquare2 to ...). In your code you are making the snake move by 3 PIXELS each time. Change them to 1's (so that your snake moves 1 GRIDSQUARE at a time) and change your snake drawing line to match mine.
You will most likely have to add a timer to slow the snake down, otherwise it will travel at the refresh rate of your monitor (60 Hz or more).
If you prefer it not to move in this fashion (incrementally from gridsquare to gridsquare) but more like how PacMan moves (smoothly from intersection to intersection) then you would have to change a lot. You have to do things like storing the last direction pressed by the player but not actually changing direction until you reach the next gridsquare. This can be done, but it's best to try doing it the way I showed above first.