Use dynamic cast for AfxGetMainFrame() macro

AfxGetMainWnd() returns the active window when no thread window is set

Fixes #3749
Make auto-hide controls code compatible with d3dfs
Make auto-hide windowed mouse pointer optional

Fixes #3750
Controls: add missing call to call RecalcLayout()
Fix uninitialized field warnings

CID 966343, 1130515
switch statements: Document intentional fall through.

Fixes CID 1130513 and 1130514.
Cosmetic: Refactor CPolygon::GetLONG for clarity.

Fixes #966539.
Avoid possible null dereferences.

Fixes CID 965991, 965992.
Remove some useless null checks.

Fixes CID 966174.
Add asserts for normally unattainable default in switch.

Fixes CID 965933, 965939, 965947, 965948.
Cosmetics: Use CheckPointer.
Use conversion constructors to work-around confusing AStyle styling.
Use a bitcheck instead of casting (WIP).

Fixes CID #965944.