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

📄 myieview.cpp

📁 myie的源代码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
		pCmdUI->m_pMenu->GetMenuString(pCmdUI->m_nID, menu, MF_BYCOMMAND);
		int i = menu.Find('(');
		if(i>0)
			menu = menu.Left(i);
		menu += "(";
		menu += sec;
		menu += ")";
		pCmdUI->SetText(menu);
	}
}

void CMyIEView::OnToolsReffre() 
{
	// TODO: Add your command handler code here
	CSetRefIntervalDlg dlg;
	dlg.m_nRefInt = m_nRefreshInterval;
	if(dlg.DoModal() == IDOK)
	{
		m_nRefreshInterval = dlg.m_nRefInt;
		((CMainFrame*)pMainFrame)->m_nDefRefreshInterval = m_nRefreshInterval;
		//change timer
		if(m_bUseAutoRef)
			ChangeRefresh();
	}
}

void CMyIEView::ChangeRefresh()
{
	if(m_nAutoRefreshTimer)
	{		//stop the timer;
		KillTimer(m_nAutoRefreshTimer);
		m_nAutoRefreshTimer = 0;
	}

	//start to scroll
	if(!m_nAutoRefreshTimer && m_bUseAutoRef && m_nRefreshInterval!=0)
	{
//			m_nScrollTimer = SetTimer(2132, (UINT)(1000*gSeed/nSpeed), NULL);
		m_nAutoRefreshTimer = SetTimer(3132, (UINT)(m_nRefreshInterval*1000), NULL);
	}

}

void CMyIEView::OnNavigateComplete2(LPCTSTR lpszURL)
{
	//2.3
	try{

	CString strUrl;
	CChildFrame* tcf = ((CChildFrame*)GetParentFrame());
	GetLocationURL(strUrl);

	if(!m_bToClose && ((IsPopUp && m_IsNewPopup) || (tcf!=NULL && !tcf->IsWindowVisible())) && !strUrl.IsEmpty())
	{
		CString url2 = strUrl.Right(m_strPossibleURL.GetLength()+13);
		if((pMainFrame->IsWindowVisible() && tcf!=NULL && !tcf->IsWindowVisible()) || url2 == "navcancl.htm#" + m_strPossibleURL /*for IE 5*/|| strUrl == "about:NavigationCanceled" /*for IE4*/ || strUrl==m_strPossibleURL)
		{
			//	CChildFrame* tcf = (CChildFrame*)GetParentFrame();
				//IsActive = FALSE;
			if(tcf!=NULL) 
			{
				tcf->PostMessage(WM_CLOSE);
				m_bToClose = TRUE;
			}

			IsPopUp = FALSE;
		}

	}


		try{

		//2.4 security flag
		if(!m_bToClose)
		{
			bVerbose = TRUE;

			LPDISPATCH pDisp = NULL;

			IHTMLDocument2 *pHTMLDoc = NULL;
			BSTR p;

			if(strUrl.Left(5)=="https")
			{

				try{
					pDisp = GetHtmlDocument();
					if( pDisp )
					{
						pDisp->QueryInterface(IID_IHTMLDocument2, (void**)&pHTMLDoc);
					}
					else
						m_bIsSecure = FALSE;

					if(pHTMLDoc)
					{
						if(SUCCEEDED(pHTMLDoc->get_protocol( &p )))
						{
							CString s(p);
							if(s=="HyperText Transfer Protocol with Privacy" || s.Find("私人验证")>0 || s.Find("玂盞")>0)
								m_bIsSecure = TRUE;
							else
								m_bIsSecure = FALSE;
							SysFreeString(p);

						}
					}

					if(IsActive && pMainFrame!=NULL)
						((CMainFrame*)pMainFrame)->m_bIsSecure = m_bIsSecure;
				}
				catch(...)
				{
				}

			}

			//zone
	/*		IInternetSecurityManager* pSecuMang = NULL;
		    HRESULT hr = CoCreateInstance(CLSID_InternetSecurityManager, NULL, 
										 CLSCTX_INPROC_SERVER, IID_IInternetSecurityManager, 
										 (LPVOID*)&pSecuMang);
			if (SUCCEEDED(hr))
			{
				DWORD zone;
				p = strUrl.AllocSysString();
				pSecuMang->MapUrlToZone(p, &zone, 0);
				SysFreeString(p);
				char tmp[5];
				itoa(zone, tmp, 10);
				AfxMessageBox(tmp);
			}
*/

			try{
		//			if(pSecuMang!=NULL)
		//				pSecuMang->Release();
					if(pHTMLDoc!=NULL)
						pHTMLDoc->Release();
					if(pDisp!=NULL)
						pDisp->Release();
			}
			catch(...)
			{
			}
		}

		}catch(...)
		{
		}

	}catch(...)
	{
	}

//2.3 end

}

void CMyIEView::OnToolsAutofilterCur() 
{
	// TODO: Add your command handler code here
	m_bAutoFilter = !m_bAutoFilter;
}

void CMyIEView::OnUpdateToolsAutofilterCur(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	//((CMainFrame*)pMainFrame)->ToolBarSetCheck(pCmdUI, m_bAutoFilter);
	pCmdUI->SetCheck(m_bAutoFilter);

	//2.5 if m_nProgess=-1 disable autofiler
	if(m_nProgress==-10)
		m_nProgress=-1;

}




void CMyIEView::OnFileSaveas() 
{
	// TODO: Add your command handler code here
	ExecWB(OLECMDID_SAVEAS, OLECMDEXECOPT_DODEFAULT,
		   NULL, NULL);
}

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


void CMyIEView::OnFilePrintSetup() 
{
	// TODO: Add your command handler code here
	ExecCommand(OLECMDID_PAGESETUP);
}

void CMyIEView::OnFileProperty() 
{
	// TODO: Add your command handler code here
	ExecCommand(OLECMDID_PROPERTIES);
}

void CMyIEView::ExecCommand(DWORD nCmdID)
{
	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, nCmdID, 0, NULL, NULL);
			lpTarget->Release();
		}
		lpDisp->Release();
	}	
}

#define RBUT_LEFT 'L'
#define RBUT_RIGHT 'R'
#define RBUT_UP 'U'
#define RBUT_DOWN 'D'

void CMyIEView::OnRButtonUp(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	try{

	if(m_bIsCapture)
	{
		m_bIsCapture = FALSE;
		ReleaseCapture();
		char dir; int i =0; m_SeqMG[0]= '\0';
		while(m_iMouseGE != m_iMouseGS)
		{
			m_SeqMG[i] = m_MouseGestures[m_iMouseGS];
			i++;
			m_SeqMG[i] = '\0';

			m_iMouseGS = (m_iMouseGS +1)%m_iMGLen;		
		}

		if(i>0)
		{
			if(strcmp(m_SeqMG, "D")==0)
				((CMainFrame*)pMainFrame)->PostMessage(WM_COMMAND, ID_NEWWINDOW, 0);
			else if(strcmp(m_SeqMG, "L")==0)
				GoBack();
			else if(strcmp(m_SeqMG, "R")==0)
				GoForward();
			else if(strcmp(m_SeqMG, "UD")==0)
				Refresh2(REFRESH_COMPLETELY);
			else if(strcmp(m_SeqMG, "RLR")==0 || strcmp(m_SeqMG, "DR")==0)
				((CMainFrame*)pMainFrame)->PostMessage(WM_COMMAND, ID_FILE_CLOSE_1, 0);
			else 
				i = 0;
		}
		
		
		if(i==0)
		{
			//popup right menu;
			POINT p2 = point;
			ClientToScreen(&p2);
			m_pCaptured = WindowFromPoint(p2);
			if(m_pCaptured)
			{
				m_pCaptured->PostMessage(WM_RBUTTONUP, nFlags, MAKELONG(point.x, point.y)); 
//				m_bRClick = TRUE;
//				QueryPerformanceCounter(&m_tLastRClick);
			}
		}
	}
	
	}catch(...)
	{
	}

	CFixedHtmlView::OnRButtonUp(nFlags, point);
}

void CMyIEView::OnMouseMove(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	try{
	if(m_bIsCapture && nFlags == MK_RBUTTON)
	{
		char dir;
		if(MoveDirection(point, &dir))
		{
			PushMouseGesture(dir);
			m_StartPoint = point;
		}
	}

	}catch(...)
	{
	}

	CFixedHtmlView::OnMouseMove(nFlags, point);
}

void CMyIEView::PushMouseGesture(char gesture)
{
	if(m_iMouseGE!=0 || m_iMouseGS !=0)
	{
		int pre = (m_iMouseGE -1 + m_iMGLen)%m_iMGLen;		
		if(m_MouseGestures[pre] == gesture)
			return;
	}

	m_MouseGestures[m_iMouseGE] = gesture;
	m_iMouseGE = (m_iMouseGE+1)%m_iMGLen;
	if(m_iMouseGS == m_iMouseGE)
		m_iMouseGS = (m_iMouseGS + 1)%m_iMGLen;

}

BOOL CMyIEView::MoveDirection(CPoint &point, char *Direction)
{
	int x = point.x - m_StartPoint.x;
	int y = point.y - m_StartPoint.y;
	int dist = x*x+y*y;
	if(dist>64)
	{
		if(x>abs(y) && x>0)
			*Direction = RBUT_RIGHT;
		else if(abs(x)>abs(y) && x<0)
			*Direction = RBUT_LEFT;
		else if(y>abs(x) && y>0)
			*Direction = RBUT_DOWN;
		else if(abs(y)>abs(x) && y<0)
			*Direction = RBUT_UP;
		else
			return FALSE;

		return TRUE;
	}
	else
		return FALSE;
}



void CMyIEView::OnFileAutosave() 
{
	// TODO: Add your command handler code here
	try{

		IHTMLDocument2 * pDoc = NULL;
		IPersistFile *pPersistFile = NULL;
		CString filename, ext, htmlname;
		int l;
		BSTR bfilename;
		char tmp[4]; 
		GetLocationURL(filename);

		pMainFrame->m_strAutoSavePath = ((CMyIEApp*)AfxGetApp())->m_strDefaultDir;
		if(pMainFrame->m_bCateWithSite)
		{
			CString site;
			GetLocationURL(site);
			site.MakeLower();
			site.Replace('\\', '/');
			l = site.Find(':');
			l++;
			if(site.GetAt(l)=='/')
				while(site.GetAt(l)=='/')
					l++;
			site = site.Mid(l);
			l =	site.Find('/');
			if(l>0)
				site = site.Left(l);
			if(site.Right(1) == ":")
				site = site.Left(site.GetLength()-1);
			static TCHAR alph[] = "abcdefghijkmnopqistuvwxyz";
			l = site.FindOneOf(alph);
			if(l>=0)
			{
				l = site.Find('.');
				if(l>0)
					site = site.Mid(l+1);
				l = site.Find('.');
				if(l>0)
					site = site.Left(l);
			}

			pMainFrame->m_strAutoSavePath += site;
			pMainFrame->m_strAutoSavePath += "\\";
			CreateDirectory(pMainFrame->m_strAutoSavePath, NULL);
		}

		if(pMainFrame->m_nAutoSave == 0 || pMainFrame->m_nAutoSave == 1 || pMainFrame->m_nAutoSave == 4 || (pMainFrame->m_nAutoSave == 3 && filename.Left(5)=="file:"))
		{
			keybd_event(VK_TAB, MapVirtualKey(VK_TAB, 0), 0, 0);
			if(pMainFrame->m_nAutoSave==1 || pMainFrame->m_nAutoSave==4)
				keybd_event('W', MapVirtualKey('W', 0), 0, 0);
			if(pMainFrame->m_nAutoSave==4)
			{
				keybd_event('A', MapVirtualKey('A', 0), 0, 0);
				keybd_event('W', MapVirtualKey('W', 0), 0, 0);
			}
			keybd_event(VK_RETURN, MapVirtualKey(VK_RETURN, 0), 0, 0);
			//set save directory
			HKEY hKey;
			if(RegOpenKey(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Internet Explorer\\Main"), &hKey) == ERROR_SUCCESS)
			{
				RegSetValueEx(hKey, _T("Save Directory"), 0, REG_SZ, (LPBYTE)(pMainFrame->m_strAutoSavePath.GetBuffer(10)), pMainFrame->m_strAutoSavePath.GetLength());
				pMainFrame->m_strAutoSavePath.ReleaseBuffer();
			}
			SendMessage(WM_COMMAND, ID_FILE_SAVEAS, 0);
		}
		else if(pMainFrame->m_nAutoSave == 2)
		{
			filename.Replace('/', '\\');
			if(filename.Right(1) == "\\")
				filename = filename.Left(filename.GetLength()-1);

			l = filename.ReverseFind('\\');
			filename = filename.Mid(l+1);
			filename.Replace(':', '_');
			l = filename.Find('?');
			if(l>0)
				filename = filename.Left(l);
			l = filename.ReverseFind('.');
			if(l>0)
			{
				ext = filename.Right(filename.GetLength()-l);
				ext.MakeLower();
				filename = filename.Left(l);
			}
			if(ext != ".htm" && ext != ".html" && ext !=".jpg" && ext != ".gif" && ext != ".shtml")
			{
				ext = ".htm";
			}
			filename = pMainFrame->m_strAutoSavePath + filename;
			l = 0;
			HFILE hf; OFSTRUCT of;
			htmlname = filename + ext;
			hf = OpenFile(htmlname, &of, OF_EXIST);
			while(hf!=HFILE_ERROR)
			{
				l++;
				htmlname = filename;
				htmlname += '[';
				itoa(l, tmp, 10);
				htmlname += tmp;
				htmlname += ']';
				htmlname += ext;
				hf = OpenFile(htmlname, &of, OF_EXIST);
			}

			if(ext != ".jpg" && ext != ".gif")
			{
				pDoc = (IHTMLDocument2*)GetHtmlDocument();
				bfilename = htmlname.AllocSysString();
				if (SUCCEEDED(pDoc->QueryInterface(IID_IPersistFile, (void**)&pPersistFile)))
					pPersistFile->Save(bfilename, FALSE);

				try{
					SysFreeString(bfilename);
					if(pPersistFile!=NULL)
						pPersistFile->Release();
					if(pDoc != NULL)
						pDoc->Release();
				}
				catch(...)
				{
				}
			}
			else
			{
				//save image
				GetLocationURL(filename);
				DWORD dwEntrySize=0;
				LPINTERNET_CACHE_ENTRY_INFO lpCacheEntry;
				if (!GetUrlCacheEntryInfo(filename,NULL,&dwEntrySize))
				{
					
				   if (GetLastError()==ERROR_INSUFFICIENT_BUFFER)
				   {
                        
					   lpCacheEntry = (LPINTERNET_CACHE_ENTRY_INFO) 
													new char[dwEntrySize];

						if (GetUrlCacheEntryInfo(filename,lpCacheEntry,&dwEntrySize))
						{
							CopyFile(lpCacheEntry->lpszLocalFileName, htmlname, FALSE);
						}

						delete lpCacheEntry;
						lpCacheEntry = NULL;
						dwEntrySize = 0;
				   }
				   else
				   {
					   //local image files
					    pMainFrame->DecodeEscap(filename);
						pMainFrame->DecodeEscap(htmlname);
						if(filename.Left(8)=="file:///")
							filename = filename.Mid(8);
						CopyFile(filename, htmlname, FALSE);
				   }
				}
			}

		}
		else if(pMainFrame->m_nAutoSave == 3)
		{
			pMainFrame->m_bIsAutoSave = TRUE;
			pMainFrame->m_pCurView = this;
			pMainFrame->SendMessage(WM_COMMAND, ID_FILE_QUICKSAVE,0);
			pMainFrame->m_bIsAutoSave = FALSE;
		}

		l = pMainFrame->FindTab((CChildFrame*)GetParentFrame());
		oldIcon = pMainFrame->SetTabIcon(7, l);
		pMainFrame->PostMessage(WM_UPDATE_TAB);

	}catch(...)
	{
	}
	
}

⌨️ 快捷键说明

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