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

📄 mainfrm.cpp

📁 一个FTP下载的源代码。代码质量非常高
💻 CPP
📖 第 1 页 / 共 5 页
字号:
	
			if (!GetLength64(transferfile.localfile, transferfile.size))
				return;
		}
		if (user!="")
		{
			transferfile.server.user=user;
			transferfile.server.pass=pass;
		}
		GetQueuePane()->AddItem(transferfile, stdtransfer, nOpen);
	}
}

void CMainFrame::OnUpdateShowtree(CCmdUI* pCmdUI) 
{
	pCmdUI->SetCheck(m_bShowTree);
}

void CMainFrame::OnShowtree() 
{
	if (!m_bShowTree)
	{
		GetLocalPane()->SetLocalFolder(GetLocalPane2()->GetLocalFolder());
		if (m_nLocalTreeViewLocation)
			m_wndLocalSplitter.ShowCol(0);
		else
			m_wndLocalSplitter.ShowRow(0);
		
		m_bShowTree=TRUE;
		m_pLocalViewHeader->bTreeHidden=FALSE;
	}
	else
	{
		m_bShowTree=FALSE;
		if (m_nLocalTreeViewLocation)
			m_wndLocalSplitter.HideCol(0);
		else
			m_wndLocalSplitter.HideRow(0);
		m_pLocalViewHeader->bTreeHidden=TRUE;
	}
	GetLocalPane()->UpdateViewHeader();
	GetLocalPane2()->UpdateViewHeader();
}

void CMainFrame::OnEditSettings() 
{
	if (COptions::GetOptionVal(OPTION_REMEMBERVIEWS))
	{
		COptions::SetOption(OPTION_SHOWNOTOOLBAR, !m_pWndToolBar->IsVisible());
		COptions::SetOption(OPTION_SHOWNOQUICKCONNECTBAR, !m_pWndDlgBar->IsVisible());
		COptions::SetOption(OPTION_SHOWNOSTATUSBAR, !m_wndStatusBar.IsVisible());
		COptions::SetOption(OPTION_SHOWNOMESSAGELOG, !m_bShowMessageLog);
		COptions::SetOption(OPTION_SHOWNOTREEVIEW, !m_bShowTree);
		COptions::SetOption(OPTION_SHOWREMOTETREEVIEW, m_bShowRemoteTree);
		COptions::SetOption(OPTION_SHOWNOQUEUE, !m_bShowQueue);
	}
	if (COptions::GetOptionVal(OPTION_REMEMBERLOCALVIEW))
	{
		COptions::SetOption(OPTION_LOCALLISTVIEWSTYLE, m_nLocalListViewStyle);
		COptions::SetOption(OPTION_HIDELOCALCOLUMNS, m_nHideLocalColumns);
		COptions::SetOption(OPTION_SHOWLOCALSTATUSBAR, GetLocalPane2()->IsStatusbarEnabled()?1:0);
	}
	if (COptions::GetOptionVal(OPTION_REMEMBERREMOTEVIEW))
	{
		COptions::SetOption(OPTION_REMOTELISTVIEWSTYLE, m_nRemoteListViewStyle);
		COptions::SetOption(OPTION_HIDEREMOTECOLUMNS, m_nHideRemoteColumns);
		COptions::SetOption(OPTION_SHOWREMOTESTATUSBAR, GetFtpPane()->IsStatusbarEnabled()?1:0);
	}
	BOOL bOldShowHiddenFiles=COptions::GetOptionVal(OPTION_ALWAYSSHOWHIDDEN);

	int nOldTransferType = COptions::GetOptionVal(OPTION_TRANSFERMODE);

	//Remember contents of quickconnect bar
	CString host, user, pass, port;
	m_pWndDlgBar->GetDlgItemText(IDC_HOST, host);
	m_pWndDlgBar->GetDlgItemText(IDC_USER, user);
	m_pWndDlgBar->GetDlgItemText(IDC_PASS, pass);
	m_pWndDlgBar->GetDlgItemText(IDC_PORT, port);

	COptions dlg(this);
	if (!dlg.Show())
		return;

	if (nOldTransferType != COptions::GetOptionVal(OPTION_TRANSFERMODE))
		m_nTransferType = COptions::GetOptionVal(OPTION_TRANSFERMODE);

	//Set the list view styles
	m_nLocalListViewStyle=COptions::GetOptionVal(OPTION_LOCALLISTVIEWSTYLE);
	m_nRemoteListViewStyle=COptions::GetOptionVal(OPTION_REMOTELISTVIEWSTYLE);
	GetFtpPane()->m_pListCtrl->SetListStyle(m_nRemoteListViewStyle);
	GetLocalPane2()->m_pListCtrl->SetListStyle(m_nLocalListViewStyle);
	GetLocalPane2()->EnableStatusbar(COptions::GetOptionVal(OPTION_SHOWLOCALSTATUSBAR));
	//Show the right columns
	m_nHideLocalColumns=COptions::GetOptionVal(OPTION_HIDELOCALCOLUMNS);
	GetLocalPane2()->m_pListCtrl->UpdateColumns(m_nHideLocalColumns);
	m_nHideRemoteColumns=COptions::GetOptionVal(OPTION_HIDEREMOTECOLUMNS);
	GetFtpPane()->m_pListCtrl->UpdateColumns(m_nHideRemoteColumns);
	GetFtpPane()->EnableStatusbar(COptions::GetOptionVal(OPTION_SHOWREMOTESTATUSBAR));
	
	
	if (m_bShowTree)
		GetLocalPane()->UpdateViewHeader();
	GetLocalPane2()->UpdateViewHeader();
	
	if (m_bShowRemoteTree)
		GetFtpTreePane()->UpdateViewHeader();
	GetFtpPane()->UpdateViewHeader();
	
	CMenu *menu2=GetMenu();
	CMenu *pMenu=new CMenu;
	if (menu2->m_hMenu!=m_hMenuDefault)
	{
		menu2->DestroyMenu();
		delete menu2;
	}
	pMenu->LoadMenu(IDR_MAINFRAME);

	//Add/remove debug menu
	if (COptions::GetOptionVal(OPTION_ENABLEDEBUGMENU))
	{
		MENUITEMINFO info={0};
		info.cbSize=sizeof(info);
		info.fMask |= MIIM_SUBMENU;
		if (!pMenu->GetMenuItemInfo(ID_MENU_DEBUG, &info))
			if (pMenu->AppendMenu(MF_STRING|MF_POPUP, ID_MENU_DEBUG, _T("&Debug")))
			{
				MENUITEMINFO info={0};
				info.cbSize=sizeof(info);
				info.fMask|=MIIM_SUBMENU;
				if (pMenu->GetMenuItemInfo(ID_MENU_DEBUG, &info))
				{
					CMenu SubMenu;
					SubMenu.CreateMenu();
					info.hSubMenu=SubMenu.Detach();
					if (SetMenuItemInfo(pMenu->m_hMenu, ID_MENU_DEBUG, FALSE, &info))
					{
						CMenu *pSubMenu=pMenu->GetSubMenu(pMenu->GetMenuItemCount()-1);
						if (pSubMenu)
						{
							pSubMenu->AppendMenu(MF_STRING, ID_MENU_DEBUG_DUMPDIRCACHE, _T("&Dump Directory &Cache"));
							pSubMenu->AppendMenu(MF_STRING, ID_MENU_DEBUG_CRASH, _T("&Crash"));
						}
					}
				}
			}
	}
	else
	{
		MENUITEMINFO info={0};
		info.cbSize=sizeof(info);
		info.fMask|=MIIM_SUBMENU;
		if (pMenu->GetMenuItemInfo(ID_MENU_DEBUG, &info))
		{
			DestroyMenu(info.hSubMenu);
			pMenu->RemoveMenu(ID_MENU_DEBUG, MF_BYCOMMAND);
		}
	}
	
	SetMenu(pMenu);
	
	CString str;
	
	m_wndQuickconnectButton.ShowWindow(SW_HIDE);
	m_wndQuickconnectButton.SetParent(this);
	delete m_pWndReBar;
	delete m_pWndDlgBar;
	delete m_pWndToolBar;
	VERIFY(CreateToolbars());
	m_wndQuickconnectButton.SetParent(m_pWndDlgBar);
	
	m_wndQuickconnectButton.SetDlgCtrlID(IDCANCEL);
	CString title = "Quick&connect";
	
	CWnd *pDlgItem = m_pWndDlgBar->GetDlgItem(IDOK);
	if (pDlgItem)
		pDlgItem->GetWindowText(title);
	m_wndQuickconnectButton.SetWindowText(title);
	CRect rect(0, 0, 20, 20);
	pDlgItem = m_pWndDlgBar->GetDlgItem(IDOK);
	if (pDlgItem)
		pDlgItem->GetWindowRect(&rect);
	m_pWndDlgBar->ScreenToClient(rect);
	m_wndQuickconnectButton.MoveWindow(rect);
	m_wndQuickconnectButton.SetDlgCtrlID(IDOK);
	m_wndQuickconnectButton.ShowWindow(SW_SHOW);
	
	VERIFY(m_wndQuickconnectButton.RemoveMenuItem(1));
	VERIFY(m_wndQuickconnectButton.RemoveMenuItem(0));
	VERIFY(m_wndQuickconnectButton.InsertMenuItem(0, ID_QUICKCONNECTBAR_MENU_BYPASS, 0));
	VERIFY(m_wndQuickconnectButton.InsertMenuItem(1, ID_QUICKCONNECTBAR_MENU_CLEAR, 0));

	m_pWndDlgBar->SetDlgItemText(IDC_HOST, host);
	m_pWndDlgBar->SetDlgItemText(IDC_USER, user);
	m_pWndDlgBar->SetDlgItemText(IDC_PASS, pass);
	m_pWndDlgBar->SetDlgItemText(IDC_PORT, port);


	//Reload the headers of the list views
	((CLocalFileListCtrl *)GetLocalPane2()->GetListCtrl())->ReloadHeader();
	((CFtpListCtrl *)GetFtpPane()->GetListCtrl())->ReloadHeader();
	((CQueueCtrl *)GetQueuePane()->GetListCtrl())->ReloadHeader();

	//Show/Hide panes
	//Hide panes disabled in options
	if (COptions::GetOptionVal(OPTION_SHOWNOTOOLBAR)==m_pWndToolBar->IsVisible())
		OnViewToolbar();
	if (COptions::GetOptionVal(OPTION_SHOWNOQUICKCONNECTBAR)==m_bShowQuickconnect)
		OnViewQuickconnectBar();
	if (COptions::GetOptionVal(OPTION_SHOWNOSTATUSBAR)==m_wndStatusBar.IsVisible())
		OnViewStatusBar();
	if (COptions::GetOptionVal(OPTION_SHOWNOMESSAGELOG)==m_bShowMessageLog)
		OnViewMessagelog();
	if (COptions::GetOptionVal(OPTION_SHOWNOTREEVIEW)==m_bShowTree)
		OnShowtree();
	if (COptions::GetOptionVal(OPTION_SHOWREMOTETREEVIEW)!=m_bShowRemoteTree)
		OnShowremotetree();
	if (COptions::GetOptionVal(OPTION_SHOWNOQUEUE)==m_bShowQueue)
		OnShowqueue();

	//Check if "Always show hidden files" has changed
	if (bOldShowHiddenFiles!=COptions::GetOptionVal(OPTION_ALWAYSSHOWHIDDEN))
	m_bShowHiddenFiles=COptions::GetOptionVal(OPTION_ALWAYSSHOWHIDDEN);
	if (m_pFileZillaApi)
	{
		m_pFileZillaApi->SetOption(FZAPI_OPTION_SHOWHIDDEN, m_bShowHiddenFiles);
		m_pFileZillaApi->SetDebugLevel(COptions::GetOptionVal(OPTION_DEBUGTRACE)?4:0);
	}

	if (COptions::GetOptionVal(OPTION_TRANSFERUSEMULTIPLE)!=((CQueueCtrl *)GetQueuePane()->GetListCtrl())->DoUseMultiple())
		((CQueueCtrl *)GetQueuePane()->GetListCtrl())->ToggleUseMultiple();

	GetQueuePane()->GetListCtrl()->SetApiCount(COptions::GetOptionVal(OPTION_TRANSFERAPICOUNT));

	if (COptions::GetOptionVal(OPTION_MINIMIZETOTRAY) == 2)
	{
		if (!m_pMinTrayBtn)
		{
			m_pMinTrayBtn = new CMinTrayBtn(this);
			m_pMinTrayBtn->Hook(this);
			m_pMinTrayBtn->MinTrayBtnShow();
		}
	}
	else
	{
		if (m_pMinTrayBtn)
		{
			m_pMinTrayBtn->Unhook();
			delete m_pMinTrayBtn;
			m_pMinTrayBtn = NULL;
		}
	}
	RedrawWindow(0, 0, RDW_FRAME | RDW_UPDATENOW | RDW_INVALIDATE);

	// Change the help file path
	TCHAR buffer[MAX_PATH + 1000];
	GetModuleFileName( 0, buffer, MAX_PATH );
	CString helpFile=buffer;
	PathRemoveArgs(helpFile);
	PathUnquoteSpaces(helpFile);
	PathRemoveFileSpec(helpFile);

	CFileStatus64 status;
	if (COptions::GetOption(OPTION_LANGUAGE) == _T("Fran鏰is") && GetStatus64(helpFile + _T("FileZillaFrench.chm"), status) && !(status.m_attribute&FILE_ATTRIBUTE_DIRECTORY))
		helpFile += _T("FileZillaFrench.chm");
	else
		helpFile += _T("FileZilla.chm");
	free((void*)AfxGetApp()->m_pszHelpFilePath);
	AfxGetApp()->m_pszHelpFilePath = _tcsdup(helpFile);

}

void CMainFrame::OnSitemanager() 
{
	CSiteManager dlg;
	int res = dlg.DoModal();
	if (res == IDOK)
		ParseSite(dlg.m_LastSite);
}

void CMainFrame::OnCancel() 
{
	int res=AfxMessageBox(IDS_QUESTION_CANCELOPERATION,MB_YESNO|MB_ICONQUESTION);
	if (res==IDYES)
		m_pCommandQueue->Cancel();
}

void CMainFrame::OnUpdateCancelbutton(CCmdUI* pCmdUI) 
{
	pCmdUI->Enable(m_pCommandQueue->IsBusy());
}

void CMainFrame::OnShowqueue() 
{
	if (!m_bShowQueue)
	{
		m_bShowQueue=TRUE;
		m_wndVertSplitter.ShowRow(2);		
	}
	else
	{
		GetQueuePane();
		m_bShowQueue=FALSE;
		m_wndVertSplitter.HideRow(2,1);
	}
	
}

void CMainFrame::OnUpdateShowqueue(CCmdUI* pCmdUI) 
{
	pCmdUI->SetCheck(m_bShowQueue);
}

void CMainFrame::OnClose() 
{
	ShowWindow(SW_HIDE);
	if (!m_bQuit)
	{
		if (!GetQueuePane()->GetListCtrl()->DoClose())
			return;
	
		m_bQuit=TRUE;

		m_pFileZillaApi->Destroy();
		return;
	}


	if (COptions::GetOptionVal(OPTION_DEFAULTFOLDERTYPE)==0)
	{
		CString folder=GetLocalPane2()->GetLocalFolder();
		COptions::SetOption(OPTION_DEFAULTFOLDER,folder);
	}

	CMenu *menu2 = GetMenu();
	if (menu2 && menu2->m_hMenu!=m_hMenuDefault)
	{
		menu2->DestroyMenu();
		delete menu2;
		SetMenu(NULL);
	}
	if (m_pMinTrayBtn)
		m_pMinTrayBtn->Unhook();
	delete m_pMinTrayBtn;
	m_pMinTrayBtn = NULL;
	CFrameWnd::OnClose();
	
}

void CMainFrame::OnProcessQueue() 
{
	if (GetQueuePane()->GetListCtrl()->DoProcessQueue())
		GetQueuePane()->GetListCtrl()->StopProcessing();
	else
		TransferQueue(1);
}

void CMainFrame::OnUpdateProcessQueue(CCmdUI* pCmdUI) 
{
	pCmdUI->Enable(!((CQueueCtrl *)GetQueuePane()->GetListCtrl())->IsQueueEmpty());
	pCmdUI->SetCheck(((CQueueCtrl *)GetQueuePane()->GetListCtrl())->DoProcessQueue()?1:0);
}

void CMainFrame::TransferQueue(int nPriority)
{
	int mode=((CQueueCtrl *)GetQueuePane()->GetListCtrl())->DoProcessQueue();
	((CQueueCtrl *)GetQueuePane()->GetListCtrl())->TransferQueue(nPriority);
}

void CMainFrame::OnToolbarDisconnect() 
{
	m_pCommandQueue->Cancel();
	m_pCommandQueue->Disconnect();
}

void CMainFrame::OnUpdateToolbarDisconnect(CCmdUI* pCmdUI) 
{
	pCmdUI->Enable(m_pCommandQueue->IsConnected() && !m_pCommandQueue->IsBusy());	
}

void CMainFrame::OnToolbarRefresh() 
{
	RefreshViews();
}

void CMainFrame::RefreshViews(int side)
{
	if (side!=1)
	{
		if (!m_pCommandQueue->IsBusy() && m_pCommandQueue->IsConnected())
			((CFtpListCtrl *)GetFtpPane()->GetListCtrl())->Refresh();
		
	}
	if (side!=2)

⌨️ 快捷键说明

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