BOOL CMiniMule::OnInitDialog() { ASSERT( GetCurrentThreadId() == g_uMainThreadId ); ASSERT( m_iInCallback == 0 ); CString strHtmlFile = theApp.GetSkinFileItem(_T("MiniMule"), _T("HTML")); if (!strHtmlFile.IsEmpty()) { if (_taccess(strHtmlFile, 0) == 0) { m_strCurrentUrl = CreateFilePathUrl(strHtmlFile, INTERNET_SCHEME_FILE); m_nHtmlResID = 0; m_szHtmlResID = NULL; m_bResolveImages = false; } } if (m_strCurrentUrl.IsEmpty()) { TCHAR szModulePath[MAX_PATH]; DWORD dwModPathLen = GetModuleFileName(AfxGetResourceHandle(), szModulePath, _countof(szModulePath)); if (dwModPathLen != 0 && dwModPathLen < _countof(szModulePath)) { m_strCurrentUrl = CreateFilePathUrl(szModulePath, INTERNET_SCHEME_RES); m_strCurrentUrl.AppendFormat(_T("/%d"), m_nHtmlResID); m_nHtmlResID = 0; m_szHtmlResID = NULL; m_bResolveImages = true; } } // TODO: Only in debug build: Check the size of the dialog resource right before 'OnInitDialog' // to ensure the window is small enough! CDHtmlDialog::OnInitDialog(); if (m_uWndTransparency) { m_layeredWnd.AddLayeredStyle(m_hWnd); m_layeredWnd.SetTransparentPercentage(m_hWnd, m_uWndTransparency); } //MORPH START - Changed by SiRoB, ModID /* SetWindowText(_T("sMule v") + theApp.m_strCurVersionLong); */ SetWindowText(_T("šMule v") + theApp.m_strCurVersionLong); //MORPH END - Changed by SiRoB, ModID return TRUE; // return TRUE unless you set the focus to a control }
BOOL CMiniMule::OnInitDialog() { ASSERT( m_iInCallback == 0 ); if (m_strCurrentUrl.IsEmpty()) { TCHAR szModulePath[MAX_PATH]; if (GetModuleFileName(AfxGetResourceHandle(), szModulePath, ARRSIZE(szModulePath))) { m_strCurrentUrl = CreateFilePathUrl(szModulePath, INTERNET_SCHEME_RES); m_strCurrentUrl.AppendFormat(_T("/%d"), m_nHtmlResID); m_nHtmlResID = 0; m_szHtmlResID = NULL; m_bResolveImages = true; } } // TODO: Only in debug build: Check the size of the dialog resource right before 'OnInitDialog' // to ensure the window is small enough! CDHtmlDialog::OnInitDialog(); if (m_uWndTransparency) { m_layeredWnd.AddLayeredStyle(m_hWnd); m_layeredWnd.SetTransparentPercentage(m_hWnd, m_uWndTransparency); } SetWindowText(_T("eMule v") + theApp.m_strCurVersionLong); return TRUE; // return TRUE unless you set the focus to a control }
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::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(); }