Use unsigned short instead of int in a few places that makes sense to do so.
Be consistent with function's variables.
Fix possible NULL pointer dereference.
disable a couple more /analyze warnings for VS2012
include/atl: remove extra arguments from format strings and use the right field type specifier.
Use the right field type specifier in function calls.

(/analyze warning C6340)
Remove unneeded variable assignments.
Use %d for integer instead of %i for consistency.
MainFrm.cpp: fix pointer field type in Format call.

(analyze warning C6273)
Reduce variable scope.