Re: OnKillfocus event eats OnClick event
The POST_MESSAGE solution is not working for me, either. The same
symptoms exist. If the record does not exist in the database, I am
sending a POST_MESSAGE event to the current window. Inside the new
message's handler, I pop up a message box to ask for confirmation of
the new record. The save button's OnClick handler never is called.
If I comment out the message box but leave everything else intact, the
OnClick handler is called. Here's the code:
void CWireInventoryGeneral::OnKillfocusCoilNumber()
{
UpdateData(TRUE);
if ( m_Coil <= _T(" ") ) return;
if ( m_Document->GetCoil (m_Coil) ) {
GetCoilData ();
} else {
// CWnd* pWindow = (CWnd*)this;
PostMessage(WM_ADDNEW_APPROVAL_NEEDED, 0, 0);
}
UpdateData(FALSE); // NOTE: I tried commenting this line out, since
it changes the display, but that had no effect
}
afx_msg LRESULT CWireInventoryGeneral::OnNewCoilNumber(WPARAM, LPARAM)
{
CString OldCoil;
OldCoil = m_Coil;
// AfxMessageBox(_T("OnNewCoilNumber()"));
CString TmpString;
CString TmpString1;
TmpString.LoadString(IDS_NOT_IN_INVENTORY);
TmpString1.LoadString(IDS_NOT_FOUND);
if ( ::MessageBox(this->m_hWnd, TmpString, TmpString1, MB_YESNO) ==
IDYES) {
m_Document->m_bAddNew = TRUE;
m_Status = m_Document->FindFreeCoilStatus();
//m_Order = _T("");
m_Cycle = _T("");
//m_Location = _T("");
m_UpdateDate = COleDateTime::GetCurrentTime();
// m_OrderCtrl.SetFocus();
} else {
m_Coil = OldCoil;
if ( m_Document->GetCoil (OldCoil) ) GetCoilData ();
}
return 0;
}