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

📄 explorer.cpp

📁 本文件包包含了大量用VC++开发的应用程序界面
💻 CPP
字号:
// Explorer.cpp : Defines the class behaviors for the application.
//

#include "stdafx.h"
#include "Explorer.h"

#include "MainFrm.h"
#include "ExplorerDoc.h"
#include "ExploreView.h"
#include "DirTreeView.h"
#include "DirListView.h"
#include	"struct.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CExplorerApp

CONFIG	g_Config;

BEGIN_MESSAGE_MAP(CExplorerApp, CWinApp)
	//{{AFX_MSG_MAP(CExplorerApp)
	ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}AFX_MSG_MAP
	// Standard file based document commands
	ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
	ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
	// Standard print setup command
	ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CExplorerApp construction

CExplorerApp::CExplorerApp()
{
	// TODO: add construction code here,
	// Place all significant initialization in InitInstance
}

/////////////////////////////////////////////////////////////////////////////
// The one and only CExplorerApp object

CExplorerApp theApp;

/////////////////////////////////////////////////////////////////////////////
// CExplorerApp initialization

BOOL CExplorerApp::InitInstance()
{
	AfxEnableControlContainer();

	// Standard initialization
	// If you are not using these features and wish to reduce the size
	//  of your final executable, you should remove from the following
	//  the specific initialization routines you do not need.

#ifdef _AFXDLL
	Enable3dControls();			// Call this when using MFC in a shared DLL
#else
	Enable3dControlsStatic();	// Call this when linking to MFC statically
#endif

	// Change the registry key under which our settings are stored.
	// TODO: You should modify this string to be something appropriate
	// such as the name of your company or organization.
	ReadRegistry();

	SetRegistryKey(_T("HAX Systems"));

	LoadStdProfileSettings();  // Load standard INI file options (including MRU)

	// Register the application's document templates.  Document templates
	//  serve as the connection between documents, frame windows and views.

	CSingleDocTemplate* pDocTemplate;
	pDocTemplate = new CSingleDocTemplate(
		IDR_MAINFRAME,
		RUNTIME_CLASS(CExplorerDoc),
		RUNTIME_CLASS(CMainFrame),       // main SDI frame window
		RUNTIME_CLASS(CExploreView));
	AddDocTemplate(pDocTemplate);

	// Parse command line for standard shell commands, DDE, file open
	CCommandLineInfo cmdInfo;
	ParseCommandLine(cmdInfo);

	// Dispatch commands specified on the command line
	if (!ProcessShellCommand(cmdInfo))
		return FALSE;

	// The one and only window has been initialized, so show and update it.
	m_pMainWnd->ShowWindow(SW_SHOW);
	m_pMainWnd->UpdateWindow();

	return TRUE;
}


/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

// Dialog Data
	//{{AFX_DATA(CAboutDlg)
	enum { IDD = IDD_ABOUTBOX };
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CAboutDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	//{{AFX_MSG(CAboutDlg)
		// No message handlers
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
	//{{AFX_DATA_INIT(CAboutDlg)
	//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAboutDlg)
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
	//{{AFX_MSG_MAP(CAboutDlg)
		// No message handlers
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

// App command to run the dialog
void CExplorerApp::OnAppAbout()
{
	CAboutDlg aboutDlg;
	aboutDlg.DoModal();
}

/////////////////////////////////////////////////////////////////////////////
// CExplorerApp message handlers


void CExplorerApp::ReadRegistry()
{
CRegKey eKey;
long	lResult;
DWORD	dwValue;
TCHAR	szPath[1024];

	lResult = eKey.Open (HKEY_CURRENT_USER, "Software\\HAX Systems\\Explorer\\Settings");
	if (lResult != ERROR_SUCCESS)
	{
		g_Config.cmdShow = SW_SHOWNORMAL;
		g_Config.rcListPane.left = 2;
		g_Config.rcListPane.top = 2;
		g_Config.rcListPane.right = 152;
		g_Config.rcListPane.bottom = 152;
		g_Config.rcTreePane.left = 2;
		g_Config.rcTreePane.top = 2;
		g_Config.rcTreePane.right = 202;
		g_Config.rcTreePane.bottom = 202;
		g_Config.rcWindow.left = 0;
		g_Config.rcWindow.top = 0;
		g_Config.rcWindow.right = 0;
		g_Config.rcWindow.bottom = 0;
		g_Config.bModified = true;
		return;
	}
	eKey.QueryValue (dwValue, "TreeHoriz");
	g_Config.rcTreePane.left = dwValue >> 16;
	g_Config.rcTreePane.right = dwValue & 0xffff;
	eKey.QueryValue (dwValue, "TreeVert");
	g_Config.rcTreePane.top = dwValue >> 16;
	g_Config.rcTreePane.bottom = dwValue & 0xffff;

	eKey.QueryValue (dwValue, "ListHoriz");
	g_Config.rcListPane.left = dwValue >> 16;
	g_Config.rcListPane.right = dwValue & 0xffff;
	eKey.QueryValue (dwValue, "ListVert");
	g_Config.rcListPane.top = dwValue >> 16;
	g_Config.rcListPane.bottom = dwValue & 0xffff;

	eKey.QueryValue (dwValue, "WindowHoriz");
	g_Config.rcWindow.left = dwValue >> 16;
	g_Config.rcWindow.right = dwValue & 0xffff;
	eKey.QueryValue (dwValue, "WindowVert");
	g_Config.rcWindow.top = dwValue >> 16;
	g_Config.rcWindow.bottom = dwValue & 0xffff;

	DWORD dwSize = sizeof (szPath);
	memset (szPath, '\0', sizeof (szPath));
	eKey.QueryValue ((LPTSTR) szPath, "StartPath", &dwSize);
	g_Config.strDirectory = szPath;
}

void CExplorerApp::WriteRegistry()
{
CRegKey eKey;
long	lResult;
DWORD	dwValue;

	if (g_Config.bModified == false)
		return;

	lResult = eKey.Create (HKEY_CURRENT_USER, "Software\\HAX Systems\\Explorer\\Settings");
	if (lResult != ERROR_SUCCESS)
		return;
	dwValue = g_Config.rcTreePane.left << 16;
	dwValue |= g_Config.rcTreePane.right;
	eKey.SetValue (dwValue, "TreeHoriz");
	dwValue = g_Config.rcTreePane.top << 16;
	dwValue |= g_Config.rcTreePane.bottom;
	eKey.SetValue (dwValue, "TreeVert");
	dwValue = g_Config.rcListPane.left << 16;
	dwValue |= g_Config.rcListPane.right;
	eKey.SetValue (dwValue, "ListHoriz");
	dwValue = g_Config.rcListPane.top << 16;
	dwValue |= g_Config.rcListPane.bottom;
	eKey.SetValue (dwValue, "ListVert");
	dwValue = g_Config.rcWindow.left << 16;
	dwValue |= g_Config.rcWindow.right;
	eKey.SetValue (dwValue, "WindowHoriz");
	dwValue = g_Config.rcWindow.top << 16;
	dwValue |= g_Config.rcWindow.bottom;
	eKey.SetValue (dwValue, "WindowVert");
	eKey.SetValue (g_Config.strDirectory, "StartPath");
}

int CExplorerApp::ExitInstance() 
{
	WriteRegistry ();
	return CWinApp::ExitInstance();
}

⌨️ 快捷键说明

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