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