/*---------------------------------------------------------------------------------------------- Handle notifications. @param ctid Identifier of the common control sending the message. @param pnmh Pointer to an NMHDR structure containing notification code and additional info. @param lnRet Value to be returned to system windows send message call. @return True if the notification has been handled, otherwise false. ----------------------------------------------------------------------------------------------*/ bool TssEdit::OnNotifyChild(int id, NMHDR * pnmh, long & lnRet) { AssertPtr(pnmh); if (SuperClass::OnNotifyChild(id, pnmh, lnRet)) return true; bool fToolTip = HasToolTip(); HWND hwndParent = ::GetParent(m_hwnd); if (fToolTip && pnmh->code == TTN_POP) { // Wait 1/2 second after the tooltip disappears before resetting the text on the // status bar. ::SetTimer(hwndParent, knToolTipTimer, 500, NULL); return true; } else if (fToolTip && pnmh->code == TTN_SHOW) { // This flag keeps the tooltip from recursively appearing and crashing the program. static bool s_fIgnore = false; if (!s_fIgnore) { // If another tooltip shows up in the 1/2 second time interval set above, cancel // the timer, so the status bar doesn't get changed back to the idle string. ::KillTimer(hwndParent, knToolTipTimer); // Create a new notification message and forward it to the parent in order to get // the default response for a normal tooltip (which is currently defined in // AfMainWnd::OnNotifyChild). NMTTDISPINFO nmtdi; nmtdi.hdr.hwndFrom = (HWND)id; nmtdi.hdr.code = TTN_GETDISPINFO; nmtdi.hdr.idFrom = ::GetDlgCtrlID((HWND)id); *nmtdi.szText = 0; ::SendMessage(::GetParent(m_hwnd), WM_NOTIFY, nmtdi.hdr.idFrom, (LPARAM)&nmtdi); // Update the status bar here rather than above after ::KillTimer() so that the // string for the new command is already set. AfMainWnd * pafw = MainWindow(); AssertPtr(pafw); AfStatusBar * pstat = pafw->GetStatusBarWnd(); if (pstat) pstat->DisplayHelpText(); if (*nmtdi.szText) { // Now we have the text for the control, so update the text in the tooltip. TOOLINFO ti = { isizeof(ti) }; ti.hwnd = (HWND)id; ti.uId = (uint)ti.hwnd; ti.lpszText = nmtdi.szText; ::SendMessage(pnmh->hwndFrom, TTM_UPDATETIPTEXT, 0, (LPARAM)&ti); // This is required so the tooltip gets resized properly. s_fIgnore = true; ::SendMessage(pnmh->hwndFrom, TTM_UPDATE, 0, 0); s_fIgnore = false; return true; } } } return false; }
/*---------------------------------------------------------------------------------------------- Load the data needed to display this view. In this case, we need to load the class, owner (so we can tell whether it is a subitem), the title, and create date. If all of these are already in the cache, don't reload it. @param pvwenv Pointer to the view environment. @param hvo The id of the object we are displaying. @param frag Identifies the part of the view we are currently displaying. @return HRESULT indicating success (S_OK), or failure (E_FAIL). ----------------------------------------------------------------------------------------------*/ STDMETHODIMP CleRecVc::LoadDataFor(IVwEnv * pvwenv, HVO hvo, int frag) { BEGIN_COM_METHOD; ChkComArgPtr(pvwenv); Assert(false); // TODO: rework StrUni stuSql; ISilDataAccessPtr qsda; CheckHr(pvwenv->get_DataAccess(&qsda)); bool fLoaded = false; int clid; CheckHr(qsda->get_IntProp(hvo, kflidCmObject_Class, &clid)); if (clid) { HVO hvoOwn; CheckHr(qsda->get_ObjectProp(hvo, kflidCmObject_Owner, &hvoOwn)); if (hvoOwn) { int64 tim; // REVIEW KenZ(RandyR) Whey are DN flids in this app? CheckHr(qsda->get_TimeProp(hvo, kflidRnGenericRec_DateCreated, &tim)); if (tim) { ITsStringPtr qtss; CheckHr(qsda->get_StringProp(hvo, kflidRnGenericRec_Title, &qtss)); if (qtss) { int cch; CheckHr(qtss->get_Length(&cch)); if (cch) fLoaded = true; } } } } if (!fLoaded) { // If any field is missing from the cache, load everything. IDbColSpecPtr qdcs; IVwOleDbDaPtr qda; CheckHr(qsda->QueryInterface(IID_IVwOleDbDa, (void**)&qda)); stuSql.Format(L"select id, Class$, Owner$, DateCreated, Title, Title_Fmt " L"from RnGenericRec_ " L"where id = %d", hvo); qdcs.CreateInstance(CLSID_DbColSpec); CheckHr(qdcs->Push(koctBaseId, 0, 0, 0)); CheckHr(qdcs->Push(koctInt, 1, kflidCmObject_Class, 0)); CheckHr(qdcs->Push(koctObj, 1, kflidCmObject_Owner, 0)); // REVIEW KenZ(RandyR) Whey are DN flids in this app? CheckHr(qdcs->Push(koctTime, 1, kflidRnGenericRec_DateCreated, 0)); CheckHr(qdcs->Push(koctString, 1, kflidRnGenericRec_Title, 0)); CheckHr(qdcs->Push(koctFmt, 1, kflidRnGenericRec_Title, 0)); AfMainWnd * pafw = AfApp::Papp()->GetCurMainWnd(); AssertPtr(pafw); AfStatusBar * pstbr = pafw->GetStatusBarWnd(); AssertPtr(pstbr); bool fProgBar = pstbr->IsProgressBarActive(); if (!fProgBar) { StrApp strMsg(kstidStBar_LoadingData); pstbr->StartProgressBar(strMsg.Chars(), 0, 70, 1); } // Execute the query and store results in the cache. CheckHr(qda->Load(stuSql.Bstr(), qdcs, hvo, 0, pstbr, NULL)); if (!fProgBar) pstbr->EndProgressBar(); } return S_OK; END_COM_METHOD(g_fact2, IID_IVwViewConstructor) }