⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 benbenbrowserview.cpp

📁 一个多窗口的浏览器的程序benbrowse
💻 CPP
📖 第 1 页 / 共 2 页
字号:
void CBenbenBrowserView::OnDownloadComplete() 
{
	// TODO: Add your specialized code here and/or call the base class
	CHtmlViewBen::OnDownloadComplete();
	try
	{
		if(!m_bePopUpWin)
		{
			CBenbenBrowserDoc* pDoc = GetDocument();
			ASSERT_VALID(pDoc);
			pDoc->AddURLToHistory (GetLocationName (),GetLocationURL() );
			
			CMainFrame * mainframe=(CMainFrame *)AfxGetApp()->m_pMainWnd;
			if(mainframe)
			{
				mainframe->StopAnimate();
				m_progress=-1;
				mainframe->SetProgressPos(m_progress);
			}
	//		if(mainframe)
	//			mainframe->SetViewIcon(this);
	
		}
		else
		{
			//	GetParentFrame()->SendMessage(WM_CLOSE);
			//	return;
		}
	}
	catch(...)
	{
	}
}


void CBenbenBrowserView::OnFilePrintPreview() 
{
	// TODO: Add your command handler code here
	try
	{
		LPOLECOMMANDTARGET lpTarget = NULL;
		LPDISPATCH lpDisp = GetHtmlDocument();
		
		if (lpDisp != NULL)
		{
			// the control will handle all printing UI
			
			if (SUCCEEDED(lpDisp->QueryInterface(IID_IOleCommandTarget,
				(LPVOID*) &lpTarget)))
			{
				lpTarget->Exec(NULL, OLECMDID_PRINTPREVIEW, 0, NULL, NULL);
				lpTarget->Release();
			}
			lpDisp->Release();
		}
	}
	catch(...)
	{
	}
	//ExecWB(OLECMDID_PRINTPREVIEW, OLECMDEXECOPT_DODEFAULT, NULL, NULL);
}

void CBenbenBrowserView::OnFilePrint() 
{
	// TODO: Add your command handler code here
	try
	{
		LPOLECOMMANDTARGET lpTarget = NULL;
		LPDISPATCH lpDisp = GetHtmlDocument();
		
		if (lpDisp != NULL)
		{
			// the control will handle all printing UI
			
			if (SUCCEEDED(lpDisp->QueryInterface(IID_IOleCommandTarget,
				(LPVOID*) &lpTarget)))
			{
				lpTarget->Exec(NULL, OLECMDID_PRINT, 0, NULL, NULL);
				lpTarget->Release();
			}
			lpDisp->Release();
		}
	}
	catch(...)
	{
	}
	//ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_DODEFAULT, NULL, NULL);
}

void CBenbenBrowserView::OnFilePrintSetup() 
{
	// TODO: Add your command handler code here
	ExecWB(OLECMDID_PAGESETUP, OLECMDEXECOPT_DODEFAULT, NULL, NULL);
}


void CBenbenBrowserView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView) 
{
	// TODO: Add your specialized code here and/or call the base class
	if(bActivate)
	{
		try
		{
			m_beActive=TRUE;
			CMainFrame * mainframe=(CMainFrame *)AfxGetApp()->m_pMainWnd;
			if(mainframe)
			{
				if(GetBusy())
					mainframe->PlayAnimate();
				else
					mainframe->StopAnimate();
				mainframe->SetAddressComText(GetLocationURL());
				mainframe->SetProgressPos(m_progress);
			}
		}
		catch(...)
		{
		}
	}
	else
		m_beActive=FALSE;
	CHtmlViewBen::OnActivateView(bActivate, pActivateView, pDeactiveView);
}

void CBenbenBrowserView::OnUpdateViewFontsLarge(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	try
	{
		COleVariant vaZoomFactor;
		ExecWB(OLECMDID_ZOOM,OLECMDEXECOPT_DONTPROMPTUSER,NULL,&vaZoomFactor);
		int fontsize=vaZoomFactor.intVal*10+1;
		pCmdUI->SetCheck(fontsize==31);
	}
	catch(...)
	{
	}
}

void CBenbenBrowserView::OnUpdateViewFontsLargest(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	try
	{
		COleVariant vaZoomFactor;
		ExecWB(OLECMDID_ZOOM,OLECMDEXECOPT_DONTPROMPTUSER,NULL,&vaZoomFactor);
		int fontsize=vaZoomFactor.intVal*10+1;
		pCmdUI->SetCheck(fontsize==41);
	}
	catch(...)
	{
	}
}

void CBenbenBrowserView::OnUpdateViewFontsMedium(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	try
	{
		COleVariant vaZoomFactor;
		ExecWB(OLECMDID_ZOOM,OLECMDEXECOPT_DONTPROMPTUSER,NULL,&vaZoomFactor);
		int fontsize=vaZoomFactor.intVal*10+1;
		pCmdUI->SetCheck(fontsize==21);
	}
	catch(...)
	{
	}
}

void CBenbenBrowserView::OnUpdateViewFontsSmall(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	try
	{
		COleVariant vaZoomFactor;
		ExecWB(OLECMDID_ZOOM,OLECMDEXECOPT_DONTPROMPTUSER,NULL,&vaZoomFactor);
		int fontsize=vaZoomFactor.intVal*10+1;
		pCmdUI->SetCheck(fontsize==11);
	}
	catch(...)
	{
	}
	
}

void CBenbenBrowserView::OnUpdateViewFontsSmallest(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	try
	{
		COleVariant vaZoomFactor;
		ExecWB(OLECMDID_ZOOM,OLECMDEXECOPT_DONTPROMPTUSER,NULL,&vaZoomFactor);
		int fontsize=vaZoomFactor.intVal*10+1;
		pCmdUI->SetCheck(fontsize==01);
	}
	catch(...)
	{
	}
}

void CBenbenBrowserView::OnStatusTextChange(LPCTSTR lpszText) 
{
	// TODO: Add your specialized code here and/or call the base class
	try
	{
		if(m_beActive)
			CHtmlViewBen::OnStatusTextChange(lpszText);
	}
	catch(...)
	{
	}
}

void CBenbenBrowserView::OnProgressChange(long nProgress, long nProgressMax) 
{
	// TODO: Add your specialized code here and/or call the base class
	try
	{
		if(m_beActive)
		{
			//CStatusBar *StatusBar=(CStatusBar*)AfxGetApp()->m_pMainWnd->GetDescendantWindow(ID_VIEW_STATUS_BAR);
			//CString str;
			if(nProgress>0&&nProgressMax>=nProgress)
			{
				m_progress=nProgress*100/nProgressMax;
				CMainFrame *pFrame=(CMainFrame *)AfxGetApp()->m_pMainWnd;
				pFrame->SetProgressPos(m_progress);
			//	str.Format("%d%%",length);
			}
			//else 
			//	str="";
	//		StatusBar->SetPaneText(StatusBar->CommandToIndex(ID_INDICATOR_PROGRESS),str);
		}
	}
	catch(...)
	{
	}
	CHtmlViewBen::OnProgressChange(nProgress, nProgressMax);
}

void CBenbenBrowserView::OnFileClose() 
{
	// TODO: Add your command handler code here
	try
	{
		Stop();
		CMainFrame *pMainFrm=(CMainFrame *)AfxGetApp()->m_pMainWnd;
		if(pMainFrm->GetChildWindowNum()>1)
		{
			CBenbenBrowserDoc *doc=GetDocument();
			ASSERT(doc);
			doc->OnCloseDocument();
		}
		else
			Navigate2(_T("about:blank"),NULL,NULL);
	}
	catch(...)
	{
	}
}

void CBenbenBrowserView::OnDocumentComplete(LPCTSTR lpszURL) 
{
	// TODO: Add your specialized code here and/or call the base class
	try
	{
		if(m_beActive)
		{
			CMainFrame *pFrame=(CMainFrame *)AfxGetApp()->m_pMainWnd;
			m_progress=-1;
			pFrame->SetProgressPos(m_progress);
		}
	}
	catch(...)
	{
	}
	CHtmlViewBen::OnDocumentComplete(lpszURL);

}

void CBenbenBrowserView::OnNavigateComplete2(LPCTSTR strURL) 
{
	// TODO: Add your specialized code here and/or call the base class
	CHtmlViewBen::OnNavigateComplete2(strURL);
}

void CBenbenBrowserView::OnDownloadBegin() 
{
	// TODO: Add your specialized code here and/or call the base class
	CHtmlViewBen::OnDownloadBegin();
}

void CBenbenBrowserView::OnTitleChange(LPCTSTR lpszText) 
{
	// TODO: Add your specialized code here and/or call the base class
	CHtmlViewBen::OnTitleChange(lpszText);
	try
	{
		CMainFrame *pMainFrm=(CMainFrame *)AfxGetApp()->m_pMainWnd;
		CString Url=GetLocationURL();
		if(pMainFrm->m_lockURLlist.Find(Url)!=NULL||m_bePopUpWin)
		{
			SignAsPopup();
			return;
		}
		else
		{
			pMainFrm->SetViewNames(lpszText,this);
			if(m_beActive)
				pMainFrm->SetAddressComText(GetLocationURL());
			GetDocument()->SetTitle(lpszText);
		}
	}
	catch(...)
	{
	}
}

bool CBenbenBrowserView::IsPopupWin()
{
	return m_bePopUpWin;
}

void CBenbenBrowserView::SignAsPopup()
{
	m_bePopUpWin=TRUE;
	PostMessage(WM_COMMAND,ID_FILE_CLOSE,0);
}



void CBenbenBrowserView::OnEditCut() 
{
	// TODO: Add your command handler code here
	ExecWB(OLECMDID_CUT, OLECMDEXECOPT_DONTPROMPTUSER, NULL, NULL); 
}

void CBenbenBrowserView::OnUpdateEditCut(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
}

void CBenbenBrowserView::OnEditPaste() 
{
	// TODO: Add your command handler code here
	ExecWB(OLECMDID_PASTE, OLECMDEXECOPT_DONTPROMPTUSER, NULL, NULL); 
}

void CBenbenBrowserView::OnUpdateEditPaste(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	
}

void CBenbenBrowserView::OnEditUndo() 
{
	// TODO: Add your command handler code here
	ExecWB(OLECMDID_UNDO, OLECMDEXECOPT_DONTPROMPTUSER, NULL, NULL); 
}

BOOL CBenbenBrowserView::OnAmbientProperty(COleControlSite* pSite, DISPID dispid, VARIANT* pvar) 
{
	// TODO: Add your specialized code here and/or call the base class
	if (dispid == DISPID_AMBIENT_DLCONTROL)
	{
		CMainFrame *pFrame=(CMainFrame *)AfxGetApp()->m_pMainWnd;
		if(pFrame)
		{
			pvar->vt = VT_I4;
			pvar->lVal = pFrame->m_dwdownloadProperty; 
			return TRUE;
		}
	}
	return CHtmlViewBen::OnAmbientProperty(pSite, dispid, pvar);
}


bool CBenbenBrowserView::IsIEHistoryAviliable()
{
	try
	{
	ITravelLogStg *m_pITravelLog = NULL;
	IServiceProvider* pISP = NULL;
	LPDISPATCH pDisp =GetApplication();
	if(pDisp!=NULL)
	{
		HRESULT hr = pDisp->QueryInterface(IID_IServiceProvider, (void**)&pISP);
		if(SUCCEEDED(hr) && pISP!=NULL) 
		{
			hr = pISP->QueryService(SID_STravelLogCursor , IID_ITravelLogStg, (void**)&m_pITravelLog);
			if(FAILED(hr))
				m_pITravelLog=NULL;
			pISP->Release();
		}
		pDisp->Release();
	}
	if(m_pITravelLog)
	{
		m_pITravelLog->Release();
		return TRUE;
	}
	}
	catch(...)
	{
	}
	return FALSE;
}

void CBenbenBrowserView::OnCommandStateChange(long nCommand, BOOL bEnable) 
{
	// TODO: Add your specialized code here and/or call the base class
	CHtmlViewBen::OnCommandStateChange(nCommand, bEnable);
	try
	{
		if (nCommand == CSC_NAVIGATEBACK)
		{
			m_bNavigateBack = bEnable ? TRUE : FALSE;
		}		
		else if (nCommand == CSC_NAVIGATEFORWARD)
		{
			m_bNavigateForward = bEnable ? TRUE : FALSE;
		}
	}
	catch(...)
	{
	}
}



BOOL CBenbenBrowserView::GetbeInUse()
{
	return m_beInUse;
}

void CBenbenBrowserView::SetbeInUse(BOOL beUsed)
{
	m_beInUse=beUsed;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -