void CMiniMule::UpdateContent(UINT uUpDatarate, UINT uDownDatarate) { ASSERT( GetCurrentThreadId() == _uMainThreadId ); if (m_bResolveImages) { static const LPCTSTR _apszConnectedImgs[] = { _T("CONNECTEDNOTNOT.GIF"), _T("CONNECTEDNOTLOW.GIF"), _T("CONNECTEDNOTHIGH.GIF"), _T("CONNECTEDLOWNOT.GIF"), _T("CONNECTEDLOWLOW.GIF"), _T("CONNECTEDLOWHIGH.GIF"), _T("CONNECTEDHIGHNOT.GIF"), _T("CONNECTEDHIGHLOW.GIF"), _T("CONNECTEDHIGHHIGH.GIF") }; UINT uIconIdx = theApp.emuledlg->GetConnectionStateIconIndex(); if (uIconIdx >= ARRSIZE(_apszConnectedImgs)) { ASSERT(0); uIconIdx = 0; } TCHAR szModulePath[_MAX_PATH]; if (GetModuleFileName(AfxGetResourceHandle(), szModulePath, ARRSIZE(szModulePath))) { CString strFilePathUrl(CreateFilePathUrl(szModulePath, INTERNET_SCHEME_RES)); CComPtr<IHTMLImgElement> elm; GetElementInterface(_T("connectedImg"), &elm); if (elm) { CString strResourceURL; strResourceURL.Format(_T("%s/%s"), strFilePathUrl, _apszConnectedImgs[uIconIdx]); elm->put_src(CComBSTR(strResourceURL)); } } } SetElementHtml(_T("connected"), CComBSTR(theApp.IsConnected() ? GetResString(IDS_YES) : GetResString(IDS_NO))); SetElementHtml(_T("upRate"), CComBSTR(theApp.emuledlg->GetUpDatarateString(uUpDatarate))); SetElementHtml(_T("downRate"), CComBSTR(theApp.emuledlg->GetDownDatarateString(uDownDatarate))); UINT uCompleted = 0; if (thePrefs.GetRemoveFinishedDownloads()) uCompleted = thePrefs.GetDownSessionCompletedFiles(); else if (theApp.emuledlg && theApp.emuledlg->transferwnd && theApp.emuledlg->transferwnd->downloadlistctrl.m_hWnd) { int iTotal; uCompleted = theApp.emuledlg->transferwnd->downloadlistctrl.GetCompleteDownloads(-1, iTotal); // [Ded]: -1 to get the count of all completed files in all categories } SetElementHtml(_T("completed"), CComBSTR(CastItoIShort(uCompleted, false, 0))); SetElementHtml(_T("freeSpace"), CComBSTR(CastItoXBytes(GetFreeTempSpace(-1), false, false))); }
void CMiniMule::Localize() { SetElementHtml(_T("connectedLabel"), CComBSTR(GetResString(IDS_CONNECTED))); SetElementHtml(_T("upRateLabel"), CComBSTR(GetResString(IDS_PW_CON_UPLBL))); SetElementHtml(_T("downRateLabel"), CComBSTR(GetResString(IDS_PW_CON_DOWNLBL))); SetElementHtml(_T("completedLabel"), CComBSTR(GetResString(IDS_DL_TRANSFCOMPL))); SetElementHtml(_T("freeSpaceLabel"), CComBSTR(GetResString(IDS_STATS_FREESPACE))); CComPtr<IHTMLElement> a; GetElementInterface(_T("openIncomingLink"), &a); if (a) { a->put_title(CComBSTR(RemoveAmbersand(GetResString(IDS_OPENINC)))); a.Release(); } GetElementInterface(_T("optionsLink"), &a); if (a) { a->put_title(CComBSTR(RemoveAmbersand(GetResString(IDS_EM_PREFS)))); a.Release(); } GetElementInterface(_T("restoreWndLink"), &a); if (a) { a->put_title(CComBSTR(RemoveAmbersand(GetResString(IDS_MAIN_POPUP_RESTORE)))); a.Release(); } CComPtr<IHTMLImgElement> img; GetElementInterface(_T("openIncomingImg"), &img); if (img) { img->put_alt(CComBSTR(RemoveAmbersand(GetResString(IDS_OPENINC)))); img.Release(); } GetElementInterface(_T("optionsImg"), &img); if (img) { img->put_alt(CComBSTR(RemoveAmbersand(GetResString(IDS_EM_PREFS)))); img.Release(); } GetElementInterface(_T("restoreWndImg"), &img); if (img) { img->put_alt(CComBSTR(RemoveAmbersand(GetResString(IDS_MAIN_POPUP_RESTORE)))); img.Release(); } }
/********************************************************************************************* Checks if the 'Title' is not null A meeting will not be stored in the scheduler if the 'Title' field is empty *********************************************************************************************/ BOOL CEntryInfoDlg::CheckValidTitle() { BOOL fRetval; CComPtr<IHTMLControlElement> pTitleControlElement; HRESULT result; if (m_szTitle.IsEmpty()) { AfxMessageBox(IDS_ENTERTITLE); result = GetElementInterface(_T("Title"), &pTitleControlElement); ASSERT(pTitleControlElement); result = pTitleControlElement->focus(); fRetval = false; } else fRetval = true; return fRetval; }
void CMiniMule::OnDocumentComplete(LPDISPATCH pDisp, LPCTSTR pszUrl) { ASSERT( GetCurrentThreadId() == _uMainThreadId ); if (theApp.emuledlg->m_pMiniMule == NULL) { // FIX ME // apperently in some rare cases (high cpu load, fast double clicks) this function is called when the object is destroyed already ASSERT(0); return; } CCounter cc(m_iInCallback); TRACE(_T("%hs: %s\n"), __FUNCTION__, pszUrl); // If the HTML file contains 'OnLoad' scripts, the HTML DOM is fully accessible // only after 'DocumentComplete', but not after 'OnNavigateComplete' CDHtmlDialog::OnDocumentComplete(pDisp, pszUrl); if (m_bResolveImages) { TCHAR szModulePath[_MAX_PATH]; if (GetModuleFileName(AfxGetResourceHandle(), szModulePath, ARRSIZE(szModulePath))) { CString strFilePathUrl(CreateFilePathUrl(szModulePath, INTERNET_SCHEME_RES)); static const struct { LPCTSTR pszImgId; LPCTSTR pszResourceId; } _aImg[] = { { _T("connectedImg"), _T("CONNECTED.GIF") }, { _T("uploadImg"), _T("UPLOAD.GIF") }, { _T("downloadImg"), _T("DOWNLOAD.GIF") }, { _T("completedImg"), _T("COMPLETED.GIF") }, { _T("freeSpaceImg"), _T("FREESPACE.GIF") }, { _T("restoreWndImg"), _T("RESTOREWINDOW.GIF") }, { _T("openIncomingImg"),_T("OPENINCOMING.GIF") }, { _T("optionsImg"), _T("PREFERENCES.GIF") } }; for (int i = 0; i < ARRSIZE(_aImg); i++) { CComPtr<IHTMLImgElement> elm; GetElementInterface(_aImg[i].pszImgId, &elm); if (elm) { CString strResourceURL; strResourceURL.Format(_T("%s/%s"), strFilePathUrl, _aImg[i].pszResourceId); elm->put_src(CComBSTR(strResourceURL)); } } CComPtr<IHTMLTable> elm; GetElementInterface(_T("table"), &elm); if (elm) { CString strResourceURL; strResourceURL.Format(_T("%s/%s"), strFilePathUrl, _T("TABLEBACKGND.GIF")); elm->put_background(CComBSTR(strResourceURL)); elm.Release(); } } } if (m_spHtmlDoc) { CComQIPtr<IHTMLElement> body; if (m_spHtmlDoc->get_body(&body) == S_OK && body) { // NOTE: The IE control will always use the size of the associated dialog resource (IDD_MINIMULE) // as the minium window size. 'scrollWidth' and 'scrollHeight' will therefore never return values // smaller than the size of that window. To have the auto-size working correctly even for // very small window sizes, the size of the dialog resource should therefore be kept very small! // TODO: Only in debug build: Check the size of the dialog resource right before 'OnInitDialog'. CComQIPtr<IHTMLElement2> body2 = body; long lScrollWidth = 0; long lScrollHeight = 0; if (body2->get_scrollWidth(&lScrollWidth) == S_OK && lScrollWidth > 0 && body2->get_scrollHeight(&lScrollHeight) == S_OK && lScrollHeight > 0) AutoSizeAndPosition(CSize(lScrollWidth, lScrollHeight)); } } Localize(); UpdateContent(); if (m_bAutoClose) CreateAutoCloseTimer(); }
HRESULT HtmlDlg::OnALinkClickedMethod(IHTMLElement *pElement) { CString attr( _T("href") ); CString href; if( !GetHtmlAttrValue( pElement, attr, href ) ) { MessageBox(_T("href error")); } MessageBox( href ); { //复选框 CComPtr<IHTMLInputElement> CkbOpen; GetElementInterface(_T("vehicle_id"), IID_IHTMLInputElement, (void **) &CkbOpen); if (CkbOpen) { VARIANT_BOOL bc=true; CkbOpen->put_checked(bc); VARIANT_BOOL b; CkbOpen->get_checked(&b); CString csb; int i = b; csb.Format(_T("%d"), i); MessageBox( csb ); } CComPtr<IHTMLElement> spP1; HRESULT hr = S_OK; CString csId = _T("car"); hr = GetElementInterface( csId, &spP1 ); if( S_OK == hr ) { CString csAttr=_T( "value" ); BSTR bStr = csAttr.AllocSysString(); VARIANT v; //spP1->get_innerHTML(&bStr); spP1->getAttribute( bStr,0, &v ); CString csShow( v.bstrVal ); MessageBox( csShow ); //spP1->put_innerHTML(bstrTable); ::VariantClear( &v ); ::SysFreeString( bStr ); } } //call js { CString csFunc = _T("showAlert()"); BSTR bStr = csFunc.AllocSysString(); VARIANT v; v.vt = VT_EMPTY; IHTMLWindow2* pWindow; HRESULT hr = m_spHtmlDoc->get_parentWindow(&pWindow); hr = pWindow->execScript( bStr, L"javascript", &v ); ::VariantClear( &v ); ::SysFreeString( bStr ); } //GotoUrl( _T("http://www.baidu.com/") ); return TRUE; }