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

📄 dirhtmldlg.cpp

📁 根据HTML的HEAD项将本机的HTML建立索引以便于浏览
💻 CPP
字号:

///********************************************************
//                               \\\|///
//                             \\  - -  //
//                              (  @ @  )
//┏━━━━━━━━━━━━━oOOo-(_)-oOOo━━━━━━━━━━━━┓
//┃☆☆☆☆☆☆   ≈≈≈大家好!我是【王晓钰】≈≈≈  ☆☆☆☆☆☆┃
//┃№№№№$$$$№№№№$$$$№№№№$$$$№№№№$$$ ┃
//┃¤¤※※※※ ≈≈≈≈≈≈谢谢大家的厚爱≈≈≈≈≈≈※※※※¤¤┃
//┃★★★★★主页“笑语小园”:http://xiaoyuyeah.yeah.net★★★★★┃
//┃★★★★★主页“笑语小园”:http://xiaoyuyeah.126.com ★★★★★┃
//┃★★★★★☆☆电子邮件:   Garden.XiaoYu@263.net  ☆☆★★★★★┃
//┃★★★★★OICQ: 285126                               ★★★★★┃
//┃☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆ ┃
//┃                                   Oooo〖王晓钰〗2001年02月12日┃
//┗━━━━━━━━━━━━━━oooO---(  )━━━━━━━━━━━━┛
//                             (   )   ) /
//                              \ (   (_/
//                               \_)
///*******************************************************
/// DirHtmlDlg.cpp : implementation file
//

#include "stdafx.h"
#include "DirHtml.h"
#include "DirHtmlDlg.h"

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

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

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

// Dialog Data
	//{{AFX_DATA(CAboutDlg)
	enum { IDD = IDD_ABOUTBOX };
	CHyperLink	m_web2;
	CHyperLink	m_web1;
	CHyperLink	m_mail;
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CAboutDlg)
	public:
	virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL);
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	//{{AFX_MSG(CAboutDlg)
	//}}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)
	DDX_Control(pDX, IDC_XY_WEB2, m_web2);
	DDX_Control(pDX, IDC_XY_WEB1, m_web1);
	DDX_Control(pDX, IDC_XY_MAIL, m_mail);
	//}}AFX_DATA_MAP
}

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

/////////////////////////////////////////////////////////////////////////////
// CDirHtmlDlg dialog

CDirHtmlDlg::CDirHtmlDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CDirHtmlDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDirHtmlDlg)
	m_dir =  _T("");
	m_disp = _T("先选择待处理的目录");
	m_output = _T("");
	m_includeSub = FALSE;
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_output = _T("IndexMaker.html");
	char buf[50];
	GetCurrentDirectory(50,buf);
	m_dir=buf;
	m_output=m_dir+"\\IndexMaker.html";
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CDirHtmlDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDirHtmlDlg)
	DDX_Text(pDX, IDC_DIR, m_dir);
	DDX_Text(pDX, IDC_DISP_CURFILE, m_disp);
	DDX_Text(pDX, IDC_OUTPUT, m_output);
	DDX_Check(pDX, IDC_CHECK_INCLUDESUB, m_includeSub);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CDirHtmlDlg, CDialog)
	//{{AFX_MSG_MAP(CDirHtmlDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_BN_CLICKED(IDC_DO, OnDo)
	ON_BN_CLICKED(IDC_ABOUT, OnAbout)
	ON_BN_CLICKED(IDC_VIEWOUTPUT, OnViewoutput)
	ON_BN_CLICKED(IDC_VIEWDIR, OnViewdir)
	ON_WM_CLOSE()
	ON_BN_CLICKED(IDC_CHECK_INCLUDESUB, OnCheckIncludesub)
	ON_BN_CLICKED(IDC_XY_HELP, OnXyHelp)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDirHtmlDlg message handlers

BOOL CDirHtmlDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Add "About..." menu item to system menu.

	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	// TODO: Add extra initialization here
	ExtractSprite.initDisplay(GetDlgItem(IDC_DISP_CURFILE));
	OnAbout();
	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CDirHtmlDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
	{
		CAboutDlg dlgAbout;
		dlgAbout.DoModal();
	}
	else
	{
		CDialog::OnSysCommand(nID, lParam);
	}
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CDirHtmlDlg::OnPaint() 
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CDirHtmlDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

void CDirHtmlDlg::OnDo() 
{
	// TODO: Add your control notification handler code here
	UpdateData();
	//ExtractSprite.creatFromFile(m_dir,m_output,"source");
	CString source;
	ExtractSprite.LoadLongResource(source,IDR_OUTPUT_SOURCE,RT_HTML);
	ExtractSprite.creat(m_dir,m_output,source);
	ExtractSprite.Do(m_includeSub);
	ShellExecute(NULL, "open",ExtractSprite.resultInfo.outFileName, NULL, NULL, SW_MAXIMIZE);
}

void CDirHtmlDlg::OnAbout() 
{
	// TODO: Add your control notification handler code here
	CAboutDlg dlg;
	dlg.DoModal();
}

void CDirHtmlDlg::OnViewoutput() 
{
	// TODO: Add your control notification handler code here
	UpdateData();
	CString filter;
	filter="网页格式(*.html)|*.html|所有文件(*.*)|*.*||";
	CFileDialog dlg(FALSE,"*.html",m_output,
		OFN_LONGNAMES|OFN_OVERWRITEPROMPT ,filter,this);
	if(dlg.DoModal()==IDOK )
	{	m_output=dlg.GetPathName();
		UpdateData(false);
	}
}

void CDirHtmlDlg::OnViewdir() 
{	char directory[50];
	strcpy(directory,(LPCTSTR)m_dir);
	if(!SelectDirDlg(directory))
	{	m_dir=directory;
		UpdateData(false);
	}
}
int CDirHtmlDlg::SelectDirDlg(char Dir[])
{	BROWSEINFO bi; 
	static ITEMIDLIST* pidl; 

	bi.hwndOwner=NULL; 
	bi.pidlRoot=NULL; 
	bi.pszDisplayName=Dir; 
	bi.lpszTitle="请选择要提取目录的文件夹";
	bi.ulFlags=BIF_RETURNONLYFSDIRS; 
	bi.lpfn=NULL; 
	bi.lParam=0; 
	bi.iImage=0; 

	pidl=SHBrowseForFolder(&bi);/*Display"SelectFolder"dialogbox,Get the foldernameandconvertit 
	intoaITEMLIST 	datastructure.*/ 
	if(pidl==NULL) 
	{	Dir[0]=0; 
		return 1;
	}
	if(!SHGetPathFromIDList(pidl,Dir))/*Retrievefoldername from ITEMLIST structure.*/ 
	{	Dir[0]=0; return 2;}
	return 0;
}

void CDirHtmlDlg::OnClose() 
{
	// TODO: Add your message handler code here and/or call default
	CDialog::OnClose();
}

void CDirHtmlDlg::OnCheckIncludesub() 
{
	// TODO: Add your control notification handler code here
	UpdateData();
}

BOOL CAboutDlg::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext) 
{
	// TODO: Add your specialized code here and/or call the base class
	m_web1.SetURL("http://XiaoyuYeah.yeah.net");
	m_web2.SetURL("http://XiaoyuYeah.126.com");
	m_mail.SetURL("mail to:Garden.XiaoYu@263.net");
	return CDialog::Create(IDD, pParentWnd);
}

void CDirHtmlDlg::OnXyHelp() 
{
	// TODO: Add your control notification handler code here
	CHelpDlg helpDlg;
	helpDlg.DoModal();
}

///********************************************************
//                               \\\|///
//                             \\  - -  //
//                              (  @ @  )
//┏━━━━━━━━━━━━━oOOo-(_)-oOOo━━━━━━━━━━━━┓
//┃☆☆☆☆☆☆   ≈≈≈大家好!我是【王晓钰】≈≈≈  ☆☆☆☆☆☆┃
//┃№№№№$$$$№№№№$$$$№№№№$$$$№№№№$$$ ┃
//┃¤¤※※※※ ≈≈≈≈≈≈谢谢大家的厚爱≈≈≈≈≈≈※※※※¤¤┃
//┃★★★★★主页“笑语小园”:http://xiaoyuyeah.yeah.net★★★★★┃
//┃★★★★★主页“笑语小园”:http://xiaoyuyeah.126.com ★★★★★┃
//┃★★★★★☆☆电子邮件:   Garden.XiaoYu@263.net  ☆☆★★★★★┃
//┃★★★★★OICQ: 285126                               ★★★★★┃
//┃☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆ ┃
//┃                                   Oooo〖王晓钰〗2001年02月12日┃
//┗━━━━━━━━━━━━━━oooO---(  )━━━━━━━━━━━━┛
//                             (   )   ) /
//                              \ (   (_/
//                               \_)
///*******************************************************
/

⌨️ 快捷键说明

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