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

📄 mainfrm.cpp

📁 一个多窗口的浏览器的程序benbrowse
💻 CPP
📖 第 1 页 / 共 5 页
字号:
	RegCloseKey(hKey);
	m_dwdownloadProperty^=DLCTL_BGSOUNDS;
	ChangeDLProperty();
	return ;
}

void CMainFrame::OnUpdateDownloadsoundTool(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->SetCheck(m_dwdownloadProperty&DLCTL_BGSOUNDS);
}

void CMainFrame::OnDownloadvideoTool() 
{
	// TODO: Add your command handler code here
	m_showvideo=!m_showvideo;
	
	HKEY            hKey;
	if(RegOpenKey(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Internet Explorer\\Main"), &hKey) != ERROR_SUCCESS)
	{
		TRACE0("multimedia setting not found\n");
		return ;
	}
	if(m_showvideo)
		RegSetValueEx(hKey,_T("Display Inline Videos"),0,REG_SZ,(LPBYTE)"yes",3);
	else
		RegSetValueEx(hKey,_T("Display Inline Videos"),0,REG_SZ,(LPBYTE)"no",2);
	RegCloseKey(hKey);
	m_dwdownloadProperty^=DLCTL_VIDEOS;
	ChangeDLProperty();
	return ;
}

void CMainFrame::OnUpdateDownloadvideoTool(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
	pCmdUI->SetCheck(m_dwdownloadProperty&DLCTL_VIDEOS);
}

void CMainFrame::GetMultimediaSettings()
{
	TCHAR           sz[MAX_PATH];
	TCHAR           szPath[MAX_PATH];
	HKEY            hKey;
	DWORD           dwSize;
	CString         qvalue;
	if(RegOpenKey(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Internet Explorer\\Main"), &hKey) != ERROR_SUCCESS)
	{
		TRACE0("multimedia settings not found\n");
		return ;
	}
	
	dwSize = sizeof(sz);
	memset(sz,NULL,MAX_PATH);
	RegQueryValueEx(hKey, _T("Display Inline Images"), NULL, NULL, (LPBYTE)sz, &dwSize);
	ExpandEnvironmentStrings(sz, szPath, MAX_PATH);
	qvalue=szPath;
	m_showimage=(qvalue=="yes")?TRUE:FALSE;
	m_dwdownloadProperty|=DLCTL_DLIMAGES;

	dwSize = sizeof(sz);
	memset(sz,NULL,MAX_PATH);
	RegQueryValueEx(hKey, _T("Play_Background_Sounds"), NULL, NULL, (LPBYTE)sz, &dwSize);
	ExpandEnvironmentStrings(sz, szPath, MAX_PATH);
	qvalue=szPath;
	m_showsound=(qvalue=="yes")?TRUE:FALSE;
	m_dwdownloadProperty|=DLCTL_BGSOUNDS;

	dwSize = sizeof(sz);
	memset(sz,NULL,MAX_PATH);
	RegQueryValueEx(hKey, _T("Display Inline Videos"), NULL, NULL, (LPBYTE)sz, &dwSize);
	ExpandEnvironmentStrings(sz, szPath, MAX_PATH);
	qvalue=szPath;
	m_showvideo=(qvalue=="yes")?TRUE:FALSE;
	m_dwdownloadProperty|=DLCTL_VIDEOS;

	dwSize = sizeof(sz);
	memset(sz,NULL,MAX_PATH);
	RegQueryValueEx(hKey, _T("Play_Animations"), NULL, NULL, (LPBYTE)sz, &dwSize);
	ExpandEnvironmentStrings(sz, szPath, MAX_PATH);
	qvalue=szPath;
	m_showanimation=(qvalue=="yes")?TRUE:FALSE;
//	m_dwdownloadProperty|=

	RegCloseKey(hKey);
	return ;
}



void CMainFrame::OnModifyUrllock() 
{
	// TODO: Add your command handler code here
	CURLLockDlg dlg;
	dlg.SetListBoxData(&m_lockURLlist);
	if(dlg.DoModal()==IDOK)
	{
		m_lockURLlist.RemoveAll();
		for(int i=0;i<dlg.m_lockurls.GetCount();i++)
			m_lockURLlist.AddTail(dlg.m_lockurls.GetAt(dlg.m_lockurls.FindIndex(i)));
		SaveDefaultData("lockURL.dat",&m_lockURLlist);
	}
}

void CMainFrame::OnMaillinkFile() 
{
	// TODO: Add your command handler code here
	CString URL;
	try
	{
		CBenbenBrowserView *view=(CBenbenBrowserView *)GetbenActiveView();
		if(view)
		{
			URL="mailto:?subject="+view->GetLocationName();
			URL+="&body=" +view->GetLocationURL();
			ShellExecute(NULL,"open",URL,NULL,NULL,SW_SHOWNORMAL); 
		}
	}
	catch(...)
	{
	}
}

void CMainFrame::RefreshFavoriteMenu()
{
	TCHAR           sz[MAX_PATH];
	TCHAR           szPath[MAX_PATH];
	HKEY            hKey;
	DWORD           dwSize;
	BCMenu*          pMenu;
	// first get rid of bogus submenu items.
	try
	{
		pMenu=(BCMenu *) CMenu::FromHandle( m_wndMenuBar.GetMenu())->GetSubMenu(3);
		if(!pMenu)
		{
			MessageBox("built favorites menu failed");
			return ;
		}
		while(pMenu->DeleteMenu(3, MF_BYPOSITION));
		
		// find out from the registry where the favorites are located.
		if(RegOpenKey(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders"), &hKey) != ERROR_SUCCESS)
		{
			TRACE0("Favorites folder not found\n");
			return ;
		}
		dwSize = sizeof(sz);
		RegQueryValueEx(hKey, _T("Favorites"), NULL, NULL, (LPBYTE)sz, &dwSize);
		ExpandEnvironmentStrings(sz, szPath, MAX_PATH);
		RegCloseKey(hKey);
		
		//get the imagelist of the OS
		CImageList m_ImageListSmall;
		HIMAGELIST hImageList;
		SHFILEINFO shFi;
		hImageList=(HIMAGELIST)SHGetFileInfo("C:\\",0,&shFi,sizeof(shFi),
			SHGFI_SYSICONINDEX|SHGFI_SMALLICON);
		m_ImageListSmall.m_hImageList=hImageList;
		
		BuildFavStruct favstruct;
		favstruct.imaglist=&m_ImageListSmall;
		favstruct.nStartPos=0;
		favstruct.pMenu=pMenu;
		favstruct.pszPath=szPath;
		favstruct.IsLinkFolder=FALSE;
		BuildFavoritesMenu(favstruct);//szPath,0, pMenu,&m_ImageListSmall);
		
		m_ImageListSmall.Detach();
		
		m_linkbar.Init();//important: BuildFavoritesMenu must be taken before call this fun to init the linkbar 
	}
	catch(...)
	{
	}
}

void CMainFrame::OnClose() 
{
	// TODO: Add your message handler code here and/or call default
	m_wndToolBar.SaveState( _T("Settings") );
    m_wndReBar.SaveState( _T("Settings") );
	SaveBenbroState();
	SaveSearchPages();
	UnregisterHotKey(m_hWnd,0);
//	AfxGetApp()->WriteProfileString("Settings","Language",m_languageName);
//	AfxGetApp()->WriteProfileInt("Settings","Proxy",m_local_pass);
	CMDIFrameWndEx::OnClose();
}

//////translation/////////////////////

void CMainFrame::SetNewLanguage(BCMenu *menu)
{
	try
	{
		CString strMenu;
		CString strMenuNew;
		
		for(unsigned int i=0;i<menu->GetMenuItemCount();i++)
		{
			
			int id=menu->GetMenuItemID(i);
			if(id==0)
				continue;
			else
			{
				menu->GetMenuText(i,strMenu,MF_BYPOSITION);
				GetText(strMenu,strMenuNew,menu_item_text);
				if(!menu->ModifyODMenu(strMenuNew,strMenu,-1))
					menu->ModifyMenu(i,MF_BYPOSITION,id,strMenuNew);
				if(id==-1)
				{
					BCMenu *menusub=(BCMenu *)menu->GetSubMenu(i);
					SetNewLanguage(menusub);
				}
			}
		}
	}
	catch(...)
	{
	}
}

void CMainFrame::GetLangulagesExist()
{
	CFileFind filefind;
	CString dirname;
	TCHAR           sz[MAX_PATH];
	GetModuleFileName(NULL,sz,sizeof(sz));
	dirname=sz;
	dirname=dirname.Left(dirname.ReverseFind('\\'));
	dirname=dirname.Left(dirname.ReverseFind('\\'));
	dirname+="\\language\\*.txt";
	if(!filefind.FindFile(dirname))
		return;
	int result=filefind.FindNextFile();
	m_language_file_name=filefind.GetFilePath();
	CString languagename;
	m_language.RemoveAll();
	for(int i=0;(i<(0xff-0x20));i++)
	{
		CStdioFile file;
		if(!file.Open(filefind.GetFilePath(),CFile::modeRead))
			continue;
		while(file.ReadString(languagename))
		{
			if(languagename.Find("languageinfo")>=0)
			{
				languagename=languagename.Mid(languagename.Find('=')+1);
				m_language.AddTail(languagename);
				if(languagename==m_languageName)
				{
					m_language_file_name=filefind.GetFilePath();
					
				}
				break;
			}
		}
		file.Close();
		if(result==0)
			return;
		result=filefind.FindNextFile();
	}
}

LRESULT CMainFrame::OnSetMessageString(WPARAM wParam, LPARAM lParam)
{
	UINT nIDLast = m_nIDLastMessage;
	m_nFlags &= ~WF_NOPOPMSG;
	
	CWnd* pMessageBar = GetMessageBar();
	CString m_sStatusBarString;
	if (pMessageBar != NULL)
	{
		CString sMsg;
		CString strMessage;
		
		// set the message bar text
		if (lParam != 0)
		{
			ASSERT(wParam == 0);    // can't have both an ID and a string
			m_sStatusBarString = (LPCTSTR)lParam;
			sMsg = m_sStatusBarString;
		}
		else if (wParam != 0)
		{
			// map SC_CLOSE to PREVIEW_CLOSE when in print preview mode
			if (wParam == AFX_IDS_SCCLOSE && m_lpfnCloseProc != NULL)
				wParam = AFX_IDS_PREVIEW_CLOSE;
			
			// get message associated with the ID indicated by wParam
			if (wParam == AFX_IDS_IDLEMESSAGE)
			{
				GetMessageString(wParam, strMessage);
				if(strMessage.Find('|')>=0)
					strMessage=strMessage.Left(strMessage.Find('|'));
				sMsg = strMessage;
				
			}
			else
			{
				GetMessageString(wParam, strMessage);
				GetText(strMessage,sMsg,menuhint_item_text);
				if(sMsg.Find('|')>=0)
					sMsg=sMsg.Left(sMsg.Find('|'));
			}
		}
		
		pMessageBar->SetWindowText(sMsg);
		
		// update owner of the bar in terms of last message selected
		CFrameWnd* pFrameWnd = pMessageBar->GetParentFrame();
		if (pFrameWnd != NULL)
		{
			m_nIDLastMessage = (UINT)wParam;
			m_nIDTracking = (UINT)wParam;
		}
	}
	
	m_nIDLastMessage = (UINT)wParam;    	// new ID (or 0)
	m_nIDTracking = (UINT)wParam;       	// so F1 on toolbar buttons work
	
	return nIDLast;
}
////////////////////////////////////////////////////////////

void CMainFrame::OnSynchronizeTool() 
{
	// TODO: Add your command handler code here
	ShellExecute(0, "open", "mobsync.exe", "", ".", SW_SHOW);
}
void CMainFrame::OnSetNewLanguage(UINT nID)
{
	UINT idstart=0x1020;
	m_languageName=m_language.GetAt(m_language.FindIndex(nID-idstart));
}

BOOL CMainFrame::IsGlobalOffline()
{
	
	DWORD dwState = 0, dwSize = sizeof(DWORD);
	BOOL fRet = FALSE;
	try
	{
		if(InternetQueryOption(NULL, 
			INTERNET_OPTION_CONNECTED_STATE, &dwState,
			&dwSize))
		{
			if(dwState & INTERNET_STATE_DISCONNECTED_BY_USER)
				fRet = TRUE;
		}
	}
	catch(...)
	{
	}
	return fRet; 
	
}

void CMainFrame::SetViewNames(CString ViewName, CView *pView)
{
	m_wndViewManager.SetViewName(ViewName,pView);
}

void CMainFrame::LoadHistoryUrls()
{
	TCHAR           sz[MAX_PATH];
	TCHAR           sz2[MAX_PATH];
	TCHAR           szPath[MAX_PATH];
	HKEY            hKey;
	DWORD           dwSize;
	try
	{
		if(RegOpenKey(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Internet Explorer\\TypedUrls"), &hKey) != ERROR_SUCCESS)
		{
			TRACE0("Favorites folder not found\n");
			return ;
		}
		CString URL;
		dwSize = sizeof(sz);
		for(int i=0;i<25;i++)
		{
			dwSize = sizeof(sz);
			memset(sz,0,dwSize);
			if(RegEnumValue(hKey,i,szPath,&dwSize,NULL,NULL,(LPBYTE)sz, &dwSize)!=ERROR_SUCCESS)
				continue;
			ExpandEnvironmentStrings(sz, sz2, MAX_PATH);
			URL=sz2;
			if(URL.GetLength()>0)
			{
				COMBOBOXEXITEM item;
				item.mask = CBEIF_TEXT|CBEIF_IMAGE|CBEIF_SELECTEDIMAGE ;
				item.iItem = 0;
				item.pszText = (LPTSTR)(LPCTSTR)URL;
				item.iImage = 1;
				item.iSelectedImage = 1;
				m_AddressCom->InsertItem(&item);
			}
		}
		RegCloseKey(hKey);
	}
	catch(...)
	{
	}
}

void CMainFrame::HideControlbarBen()
{
	ShowControlBar(&m_wndToolBar, FALSE, FALSE);
	ShowControlBar(&m_wndStatusBar, FALSE, FALSE);
	ShowControlBar(&m_wndMenuBar, FALSE, FALSE);
}

void CMainFrame::ShowControlbarBen()
{
	
	ShowControlBar(&m_wndToolBar, TRUE, FALSE);
	ShowControlBar(&m_wndStatusBar, TRUE, FALSE);
	ShowControlBar(&m_wndMenuBar, TRUE, FALSE);
}

void CMainFrame::InstallCollBar()
{
	if (!m_wndMyBar1.Create(_T("my coolbar"), this, CSize(230,260),TRUE,ID_VIEW_COOLBAR,WS_CHILD|CBRS_TOP))
	{
		TRACE0("Failed to create mybar\n");
		return ;
	}
	
	m_TabCtrl.Create(TCS_DOWNBEN|WS_CHILD|WS_VISIBLE,CRect(0,0,100,100),&m_wndMyBar1,ID_VIEW_COOLBAR+1);
	m_wndTreeHisty.Create(NULL,NULL, WS_CHILD,CRect(0,0,0,0), &m_TabCtrl, 100);
	m_wndTree.Create(NULL,NULL, WS_CHILD,CRect(0,0,0,0), &m_TabCtrl, 100);
	
	CString strFull,strNew,strText;
    if(strFull.LoadString(ID_VIEW_FAVORITE_BAR))
	{
		GetText(strFull,strNew,menuhint_item_text);
		(AfxExtractSubString( strText, strNew, 1, _T('|')));	
	}
	
	m_TabCtrl.AddPage(&m_wndTree,strText,0);

	if(strFull.LoadString(ID_VIEW_COOLBAR))
	{
		GetText(strFull,strNew,menuhint_item_text);
		(AfxExtractSubString( strText, strNew, 1, _T('|')));	
	}
	
	m_TabCtrl.AddPage(&m_wndTreeHisty,strText,0);
	//	m_TabCtrl.SetActivePage(1);
	m_TabCtrl.UpdateWindow();
	m_TabCtrl.SetStyleDirection(m_coolbarStyle);
	m_wndMyBar1.SetBarStyle(m_wndMyBa

⌨️ 快捷键说明

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