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

📄 myieview.cpp

📁 myie的源程序是用VC++写自已可以扩搌使用
💻 CPP
📖 第 1 页 / 共 3 页
字号:

	CRect rect, oldrect;
	m_wndBrowser.GetWindowRect(&oldrect);
	GetParentFrame()->GetClientRect(&rect);
	rect.left-=2;
	rect.top-=2;
	rect.right +=2;
	rect.bottom +=2;


	if(pMainFrame!=NULL && lpszURL!=NULL && EnablePopupFilter && strcmp(lpszURL, "about:blank")!=0)
	{
		//mutex
//		WaitForSingleObject(m_hMutex, INFINITE);

		if(((CMainFrame*)pMainFrame)->m_astrPopup.Find(lpszURL)!=NULL || PopFilterStar(lpszURL))
		{
			if(pbCancel!=NULL)
				*pbCancel = TRUE;
			IsPopUp = TRUE;
			m_strPossibleURL = lpszURL;
		}
		else
		{
			m_nProgress = 0;
			if(IsActive)
			{	
				percent = m_nProgress;
			}
		}

		//mutex
//		ReleaseMutex(m_hMutex);

	}

	CChildFrame* tcf = (CChildFrame*)GetParentFrame();
	CMainFrame* mf = (CMainFrame*)(tcf->GetParentFrame());

	if(oldrect.Width()!=rect.Width() || oldrect.Height()!=rect.Height())
	{
		m_wndBrowser.MoveWindow(rect);
	}

	//mutex
//	WaitForSingleObject(m_hMutex, INFINITE);
	if(!IsPopUp && bDelayAdd && tcf!=NULL && mf!=NULL)
	{
		tcf->ShowWindow(SW_SHOW);

		bDelayAdd = FALSE;


		//add tab
		mf->AddNewTab(tcf);

		int nTabID = mf->FindTab(tcf);
		//active window
		if(mf->m_bActiveNewWindow)
		{
			mf->MDIActivate(tcf);
			//select current tab
			mf->m_wndTab.SetCurSel( nTabID );

		}

		//set icon
		oldIcon = mf->SetTabIcon( 0, nTabID );

		//update tab bar
		mf->PostMessage(WM_UPDATE_TAB);
		mf->PostMessage(WM_UPDATE_TAB_TIP);
	}
//11/4
/*	if(IsActive && tcf!=NULL && mf!=NULL)
	{
		int nTabID = mf->FindTab(tcf);
		mf->m_wndTab.SetCurSel( nTabID );
	}
*/

	//mutex
//	ReleaseMutex(m_hMutex);
}

// these are all simple one-liners to do simple controlling of the browser
void CMyIEView::OnGoBack()
{
	GoBack();
}

void CMyIEView::OnGoForward()
{
	GoForward();
}

void CMyIEView::OnGoStartPage()
{
	GoHome();
}

void CMyIEView::OnViewStop()
{
	Stop();
	m_nProgress = -1;
	if(IsActive)
		percent = m_nProgress;


		//set icon
	if(pMainFrame!=NULL)
	{
		//mutex
//		WaitForSingleObject(m_hMutex, INFINITE);

		int nTabID = ((CMainFrame*)pMainFrame)->FindTab((CChildFrame*)GetParentFrame());
		int nIcon =0;
		if(!IsActive)
			oldIcon = ((CMainFrame*)pMainFrame)->SetTabIcon( 5, nTabID );
		else if(((CChildFrame*)GetParentFrame())->bLock)
			oldIcon = ((CMainFrame*)pMainFrame)->SetTabIcon( 4, nTabID );
		else if(((CChildFrame*)GetParentFrame())->bProtect)
			oldIcon = ((CMainFrame*)pMainFrame)->SetTabIcon( 6, nTabID );
		else
		{
			oldIcon = ((CMainFrame*)pMainFrame)->SetTabIcon( -1, nTabID );
			nIcon = -1;
		}

		//update tab bar
		pMainFrame->PostMessage(WM_UPDATE_TAB);

		//mutex
//		ReleaseMutex(m_hMutex);
	}


}

void CMyIEView::OnViewRefresh()
{
	if(!m_bForceRefresh || m_lpszUrl.IsEmpty())
	{
		short ks=GetKeyState(VK_CONTROL);
		if(ks<0)
		{
			DeleteUrlCacheEntry(m_lpszUrl);
			Refresh2(REFRESH_COMPLETELY);
		}
		else
			Refresh2(REFRESH_NORMAL);
	}
	else
	{
		Navigate2(m_lpszUrl, 0, NULL);
		m_bForceRefresh = FALSE;
	}
}


// these functions control the font size.  There is no explicit command in the
// CFixedHtmlView class to do this, but we can do it by using the ExecWB() function.
void CMyIEView::OnViewFontsLargest()
{
	nDefFontSize = m_nFontSize = 0;
	COleVariant vaZoomFactor(4l);

	ExecWB(OLECMDID_ZOOM, OLECMDEXECOPT_DONTPROMPTUSER,
		   &vaZoomFactor, NULL);

}

void CMyIEView::OnViewFontsLarge()
{
	nDefFontSize = m_nFontSize = 1;

	COleVariant vaZoomFactor(3l);

	ExecWB(OLECMDID_ZOOM, OLECMDEXECOPT_DONTPROMPTUSER,
		   &vaZoomFactor, NULL);

}

void CMyIEView::OnViewFontsMedium()
{
	nDefFontSize = m_nFontSize = 2;
	COleVariant vaZoomFactor(2l);

	ExecWB(OLECMDID_ZOOM, OLECMDEXECOPT_DONTPROMPTUSER,
		   &vaZoomFactor, NULL);

}

void CMyIEView::OnViewFontsSmall()
{
	nDefFontSize = m_nFontSize = 3;

	COleVariant vaZoomFactor(1l);

	ExecWB(OLECMDID_ZOOM, OLECMDEXECOPT_DONTPROMPTUSER,
		   &vaZoomFactor, NULL);

}

void CMyIEView::OnViewFontsSmallest()
{
	nDefFontSize = m_nFontSize = 4;
	COleVariant vaZoomFactor(0l);

	ExecWB(OLECMDID_ZOOM, OLECMDEXECOPT_DONTPROMPTUSER,
		   &vaZoomFactor, NULL);

}


void CMyIEView::OnNewWindow2(LPDISPATCH* ppDisp, BOOL* Cancel) 
{
	// TODO: Add your specialized code here and/or call the base class

    // Get a pointer to the application object
    CWinApp* pApp = AfxGetApp();

	CChildFrame *pWnd = NULL;

	//mutex
//	WaitForSingleObject(m_hMutex, INFINITE);

	if(pApp!=NULL && pApp->m_pMainWnd!=NULL)
		pWnd = ((CMainFrame*)pApp->m_pMainWnd)->NewChildWindow(0,1, NULL, this);

	//mutex
//	ReleaseMutex(m_hMutex);

	if(pWnd!=NULL)
	{
		//this maybe a blank window.
		if(((CChildFrame*)GetParentFrame())->m_pBlankChild != pWnd)
		{
			((CChildFrame*)GetParentFrame())->m_pBlankChild = pWnd;
			QueryPerformanceCounter(&((CChildFrame*)GetParentFrame())->m_tBlankChild);
		}
		else
			((CChildFrame*)GetParentFrame())->m_pBlankChild = NULL;

		pWnd->m_pView->dwProperty = dwProperty;

		pWnd->m_pView->m_IsNewPopup = TRUE;

		*ppDisp = pWnd->m_pView->GetApplication();
	}

 	CFixedHtmlView::OnNewWindow2(ppDisp, Cancel);
	
}





void CMyIEView::OnProgressChange(long nProgress, long nProgressMax) 
{
	// TODO: Add your specialized code here and/or call the base class
	int oldp = m_nProgress;
	if(nProgressMax>0 && nProgress>=0)
	{
		
		m_nProgress  = nProgress/(nProgressMax/100);
		if(m_nProgress>100)
			m_nProgress=100;
	}
	else
	{
		m_nProgress = -1;
		CString strUrl = GetLocationURL();
		if((strUrl != "" && !strUrl.IsEmpty()))
			m_lpszUrl = strUrl;
	}

	if(IsActive)
	{	
		percent = m_nProgress;

		//start to scroll
		if(m_nScrollTimer==0 && m_bUseAutoScroll && m_nSrSpeed!=0)
		{
			if(m_nProgress==100 || m_nProgress<0 || (!m_bScrollAfterDL && m_nProgress>=20))
			{
				m_nScrollTimer = SetTimer(2000, 1000*gSeed/m_nSrSpeed, NULL);
			}
		}
		else if(m_nScrollTimer && m_nProgress<20 && m_nProgress>0)
		{
			//stop the timer;
			if(m_nScrollTimer)
				KillTimer(m_nScrollTimer);
			m_nScrollTimer = 0;

		}

	}

	//mutex
//	WaitForSingleObject(m_hMutex, INFINITE);

	//set icon
	if(pMainFrame!=NULL)
	{
		int nTabID = ((CMainFrame*)pMainFrame)->FindTab((CChildFrame*)GetParentFrame());
		int nIcon = m_nProgress/25;
		int oi = oldIcon;
		if(m_nProgress<0)
			nIcon=-1;
		if(nIcon==4)
			nIcon=3;

		if(m_nProgress>=0 && nIcon != oi)
			oldIcon = ((CMainFrame*)pMainFrame)->SetTabIcon( nIcon, nTabID );
		else if(m_nProgress<0)
		{
			if(!IsActive)
				oldIcon = ((CMainFrame*)pMainFrame)->SetTabIcon( 5, nTabID );
			else if(((CChildFrame*)GetParentFrame())->bLock)
				oldIcon = ((CMainFrame*)pMainFrame)->SetTabIcon( 4, nTabID );
			else if(((CChildFrame*)GetParentFrame())->bProtect)
				oldIcon = ((CMainFrame*)pMainFrame)->SetTabIcon( 6, nTabID );
			else
				oldIcon = ((CMainFrame*)pMainFrame)->SetTabIcon( -1, nTabID );
		}

		//update tab bar
		if(m_nProgress*oldp<=0 && oi*oldIcon<=0)
			pMainFrame->PostMessage(WM_UPDATE_TAB);
	}

	//mutex
//	ReleaseMutex(m_hMutex);

	CFixedHtmlView::OnProgressChange(nProgress, nProgressMax);
}


void CMyIEView::OnEditCopy() 
{
	// TODO: Add your command handler code here
	ExecWB(OLECMDID_COPY, OLECMDEXECOPT_DONTPROMPTUSER,
	   NULL, NULL);

}

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

}

void CMyIEView::OnEditFind() 
{
	// TODO: Add your command handler code here
	((CMainFrame*)pMainFrame)->ExecCmdTarget(HTMLID_FIND, this);
}

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

void CMyIEView::OnEditSelectAll() 
{
	// TODO: Add your command handler code here
	ExecWB(OLECMDID_SELECTALL, OLECMDEXECOPT_DONTPROMPTUSER,
	   NULL, NULL);
	
}

void CMyIEView::OnStatusTextChange(LPCTSTR lpszText) 
{
	// TODO: Add your specialized code here and/or call the base class
	if(IsActive)
	{
		if(bURLOnly && m_nProgress<0 && lpszText!=NULL && strlen(lpszText)!=0)
		{
			char* pdes = strchr(lpszText, ':');
			if((pdes==NULL || pdes - lpszText>10) && strncmp(lpszText,"Shortcut", 8)!=0 && strstr(lpszText, "的快捷方式")==NULL)
				return;
		}
		CFixedHtmlView::OnStatusTextChange(lpszText);
	}
}

BOOL CMyIEView::OnAmbientProperty(COleControlSite* pSite, DISPID dispid, VARIANT* pvar) 
{
	// TODO: Add your specialized code here and/or call the base class
	if (dispid == DISPID_AMBIENT_DLCONTROL)
	{
 	  dwProperty |= DLCTL_SILENT;
	  if(!bSilent)
		  dwProperty -= DLCTL_SILENT;

	  pvar->vt = VT_I4;
	  pvar->lVal = dwProperty; 
	  //DLCTL_DLIMAGES  | DLCTL_NO_SCRIPTS | DLCTL_NO_JAVA
	//				 | DLCTL_NO_RUNACTIVEXCTLS | DLCTL_NO_DLACTIVEXCTLS;

	  return TRUE;

	}

	return CFixedHtmlView::OnAmbientProperty(pSite, dispid, pvar);
	

}

void CMyIEView::OnOptionsLoadimage() 
{
	// TODO: Add your command handler code here
	dwProperty ^= DLCTL_DLIMAGES;
	m_bForceRefresh = TRUE;

}

void CMyIEView::OnUpdateOptions(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	switch (pCmdUI->m_nID)
	{
	case ID_OPTIONS_LOADIMAGE:
	/*	if(dwProperty&DLCTL_DLIMAGES)
			pCmdUI->SetCheck(1);
		else
			pCmdUI->SetCheck(0);*/
		if(dwProperty&DLCTL_DLIMAGES)
		{
			if(((CMainFrame*)pMainFrame)->m_strBGPic == "" || pCmdUI->m_pMenu !=NULL)
				pCmdUI->SetCheck();
			else
			{
				pCmdUI->SetCheck(0);
				((CMainFrame*)pMainFrame)->m_wndToolBar.GetToolBarCtrl().PressButton(pCmdUI->m_nID, TRUE);
			}
		}
		else
		{
			((CMainFrame*)pMainFrame)->m_wndToolBar.GetToolBarCtrl().PressButton(pCmdUI->m_nID, FALSE);
			pCmdUI->SetCheck(0);
		}
		break;
	case ID_OPTIONS_LOADVIDEOS:
		if(dwProperty&DLCTL_VIDEOS)
			pCmdUI->SetCheck(1);
		else
			pCmdUI->SetCheck(0);
		break;
	case ID_OPTIONS_LOADSOUNDS:
		if(dwProperty&DLCTL_BGSOUNDS)
			pCmdUI->SetCheck(1);
		else
			pCmdUI->SetCheck(0);
		break;
	case ID_OPTIONS_ALLOWSCRIPTS:
		if(dwProperty&DLCTL_NO_SCRIPTS)
			pCmdUI->SetCheck(0);
		else
			pCmdUI->SetCheck(1);
		break;
	case ID_OPTIONS_ALLOWJAVAAPPLET:
		if(dwProperty&DLCTL_NO_JAVA)
			pCmdUI->SetCheck(0);
		else
			pCmdUI->SetCheck(1);
		break;
	case ID_OPTIONS_ALLOWACTIVEX:
		if(dwProperty&DLCTL_NO_RUNACTIVEXCTLS)
			pCmdUI->SetCheck(0);
		else
			pCmdUI->SetCheck(1);

⌨️ 快捷键说明

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