static tstring format_fetch_time(const CQuotesProviderBase&, MCONTACT hContact, const tstring& rsFormat) { time_t nTime; if (true == get_fetch_time(hContact, nTime)) { boost::posix_time::ptime time = boost::date_time::c_local_adjustor<boost::posix_time::ptime>::utc_to_local(boost::posix_time::from_time_t(nTime)); tostringstream k; k.imbue(std::locale(GetSystemLocale(), new ttime_facet(rsFormat.c_str()))); k << time; return k.str(); } return tstring(); }
INT_PTR CALLBACK QuoteInfoDlgProcImpl(MCONTACT hContact, HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_INITDIALOG: assert(hContact); TranslateDialogDefault(hdlg); { tstring sDescription = GetContactName(hContact); ::SetDlgItemText(hdlg, IDC_STATIC_QUOTE_NAME, sDescription.c_str()); double dRate = 0.0; if (true == Quotes_DBReadDouble(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_PREV_VALUE, dRate)) { tostringstream o; o.imbue(GetSystemLocale()); o << dRate; ::SetDlgItemText(hdlg, IDC_EDIT_PREVIOUS_RATE, o.str().c_str()); } dRate = 0.0; if (true == Quotes_DBReadDouble(hContact, QUOTES_PROTOCOL_NAME, DB_STR_QUOTE_CURR_VALUE, dRate)) { tostringstream o; o.imbue(GetSystemLocale()); o << dRate; ::SetDlgItemText(hdlg, IDC_EDIT_RATE, o.str().c_str()); } time_t nFetchTime; if (true == get_fetch_time(nFetchTime, hContact)) { TCHAR szTime[50] = { 0 }; if (0 == _tctime_s(szTime, 50, &nFetchTime)) { ::SetDlgItemText(hdlg, IDC_EDIT_RATE_FETCH_TIME, szTime); } } CQuotesProviders::TQuotesProviderPtr pProvider = CModuleInfo::GetQuoteProvidersPtr()->GetContactProviderPtr(hContact); const IQuotesProvider::CProviderInfo& pi = pProvider->GetInfo(); tostringstream o; o << TranslateT("Info provided by") << _T(" <a href=\"") << pi.m_sURL << _T("\">") << pi.m_sName << _T("</a>"); ::SetDlgItemText(hdlg, IDC_SYSLINK_PROVIDER, o.str().c_str()); } return TRUE; case WM_NOTIFY: LPNMHDR pNMHDR = reinterpret_cast<LPNMHDR>(lParam); switch (pNMHDR->code) { case NM_CLICK: if (IDC_SYSLINK_PROVIDER == wParam) { PNMLINK pNMLink = reinterpret_cast<PNMLINK>(pNMHDR); ::ShellExecute(hdlg, _T("open"), pNMLink->item.szUrl, NULL, NULL, SW_SHOWNORMAL); } break; } break; } return FALSE; }