/*---------------------------------------------------------------------------------------------- Close the current editor, saving changes that were made. hwnd is the editor hwnd. @param fForce True if we want to force the editor closed without making any validity checks or saving any changes. ----------------------------------------------------------------------------------------------*/ void AfDeFeEdBoxBut::EndEdit(bool fForce) { SuperClass::EndEdit(fForce); if (!fForce) { if (!SaveEdit()) { Assert(false); // Should have called IsOkToClose() first. } EndTempEdit(); SaveFullCursorInfo(); } // Get rid of the edit box and button. ::DestroyWindow(m_hwnd); m_hwnd = 0; m_hwndButton = 0; }
/*---------------------------------------------------------------------------------------------- The Ok button in the list chooser has been hit. Process the results from the list chooser. @param pplc Pointer to the dialog box being closed. ----------------------------------------------------------------------------------------------*/ void AfDeFeCliRef::ChooserApplied(PossChsrDlg * pplc) { // Get the output values. StrUni stu; ITsStringPtr qtss; ITsStrFactoryPtr qtsf; HVO pssId; qtsf.CreateInstance(CLSID_TsStrFactory); pplc->GetDialogValues(pssId); m_pss = pssId; m_fRecurse = true; if (pssId) { PossListInfoPtr qpli; AfLpInfo * plpi = GetLpInfo(); AssertPtr(plpi); plpi->LoadPossList(m_hvoPssl, m_wsMagic, &qpli); AssertPtr(qpli); int ipss = qpli->GetIndexFromId(pssId); PossItemInfo * ppii = qpli->GetPssFromIndex(ipss); if (m_fHier) ppii->GetHierName(qpli, stu, m_pnt); else ppii->GetName(stu, m_pnt); int ws = ppii->GetWs(); qtsf->MakeStringRgch(stu.Chars(), stu.Length(), ws, &qtss); m_qtss = qtss; ::SendMessage(m_hwnd, FW_EM_SETTEXT, 0, (LPARAM)qtss.Ptr()); } else { m_qtss = NULL; ::SendMessage(m_hwnd, FW_EM_SETTEXT, 0, NULL); } // I (KenZ) don't fully understand this. But if a user enters the chooser, and opens a // list editor from there and adds a new item, closes the list editor, checks the new // item in the chooser, selects OK, then moves to the next record without moving from // the field, the added item is lost. We get ksyncPossList and ksyncAddPss sync messages // from the list editor, but for some reason we are getting an extra ksyncPossList // message after this method completes. That extra message is calling ListChanged which // calls UpdateField, which reloads our temporary cache from the main cache and wipes out // the change we just made. So until we can do something better, we'll save the changes // here to make sure the UpdateField doesn't wipe out our change. SaveEdit(); ::InvalidateRect(m_hwnd, NULL, true); }