First of all I would like to welcome you to this forums and secondly would like to request you to avoid multiple postings like http://www.go4expert.com/showthread.php?t=308
in multiple sections. I know you are really looking for the solutions but if somone is willing to help you out he will find the question he is an expert in.
Now about your query. It would have been better if you would have posted some thing like I have problem in ... area then many more developers would have been interested. But anyway
if(mi.fState = MFS_CHECKED)
// Toolbar on?
dr.top = 45;
margin += 45;
dr.top = 5;
In the above code you are checking the toolbar On/Off but no where in the code you are checking for the status bar. Do the same and everything should be fine.