HRESULT CMiniMule::OnOptions(IHTMLElement* pElement) { CCounter cc(m_iInCallback); if (theApp.emuledlg->IsRunning()) { // showing the 'Pref' dialog will process the message queue -> timer messages will be dispatched -> kill auto close timer! KillAutoCloseTimer(); if (theApp.emuledlg->ShowPreferences() == -1) MessageBeep(MB_OK); if (GetAutoClose()) CreateAutoCloseTimer(); } return S_OK; }
void CMiniMule::OnTimer(UINT nIDEvent) { if (m_bAutoClose && nIDEvent == m_uAutoCloseTimer) { KillAutoCloseTimer(); CPoint pt; GetCursorPos(&pt); CRect rcWnd; GetWindowRect(&rcWnd); if (!rcWnd.PtInRect(pt)) PostMessage(WM_CLOSE); else CreateAutoCloseTimer(); } CDHtmlDialog::OnTimer(nIDEvent); }
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(); }