Well, this won't work because the control is the child of your View class; not the CMainFrame class. I have two suggestions: The first one is the easier way: Don't try to validate the data everytime you loose focus. Instead, validate it when the user clicks on OK button. If you want to do it whenever the window looses focus do it this way: Create a bool variable as a member of your view. Lets say m_bChildHasFocus Now, whenever the control gets the focus set the variable to true and whenever it looses set it false. Here is the code:void DataImportDlg2::OnKillfocusProtocolNameCb() { if (!m_bChildHasFocus) return CView::OnKillFocus(); // or whatever! I am not sure. Just exit the function properly!! m_bChildHasFocus = false; CString protoName; // Get the protocol item just typed in. m_protocolNameCB.GetWindowText(protoName); // If an item was typed in // verify this protocol exists. if (protoName.GetLength() > 0) { int index = m_protocolNameCB.FindStringExact(0, protoName); if (index == CB_ERR) { MessageBox (_T ("Protocol does not exist, to create it, use the Create Protocol button"), _T ("Data Import"), MB_ICONERROR | MB_OK | MB_APPLMODAL | MB_TOPMOST); m_protocolNameCB.SetFocus(); m_bChildHasFocus = true; }
Also, don't forget to add the OnGetFocus function. In OnGetFocus functions, just set m_bChildHasFocus = true. Mustafa Demirhan http://www.macroangel.com Sonork ID 100.9935:zoltrix
They say I'm lazy but it takes all my time