Just an aside remark and advice.
No offense, your CXRayFIDlg::OnCtlColor looks like a mess, then it's no wonder that you can easily make mistakes in it. Too much code, too many conditions, too many...