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

📄 htmleditordlg.cpp

📁 HTML Editor for VC++ 6.0:Today, applications often need a rich user interface. One of them is abilit
💻 CPP
字号:
// HtmlEditorDlg.cpp : implementation file
//

#include "stdafx.h"
#include "HtmlEditor.h"
#include "HtmlEditorDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CHtmlEditorDlg dialog

CHtmlEditorDlg::CHtmlEditorDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CHtmlEditorDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CHtmlEditorDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CHtmlEditorDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CHtmlEditorDlg)
	DDX_Control(pDX, IDC_EXPLORER1, m_ctrlWeb);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CHtmlEditorDlg, CDialog)
	//{{AFX_MSG_MAP(CHtmlEditorDlg)
	ON_BN_CLICKED(IDC_GET_HTML, OnGetHtml)
	ON_BN_CLICKED(IDC_BOLD, OnBold)
	ON_BN_CLICKED(IDC_ITALIC, OnItalic)
	ON_BN_CLICKED(IDC_UNDERLINE, OnUnderline)
	ON_BN_CLICKED(IDC_IMAGE, OnImage)
	ON_BN_CLICKED(IDC_HYPERLINK, OnHyperlink)
	ON_BN_CLICKED(IDC_UNDO, OnUndo)
	ON_BN_CLICKED(IDC_REDO, OnRedo)
	ON_BN_CLICKED(IDC_SOURCE, OnSource)
	ON_BN_CLICKED(IDC_TH, OnTh)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CHtmlEditorDlg message handlers

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

	//let's naviage to TH website - this document will be editable!
	m_ctrlWeb.Navigate("http://www.codeguru.com", NULL, NULL, NULL,NULL);
	
	//you could call this fuction even now - but Internet Explorer prior to 6.0 want to document to be loaded before enterning designer mode
	//so we will do it in OnNavigateComplete2Explorer1 funtion.
	//m_ctrlWeb.SetDesignMode(TRUE);

	return TRUE;  // return TRUE  unless you set the focus to a control
}

BEGIN_EVENTSINK_MAP(CHtmlEditorDlg, CDialog)
    //{{AFX_EVENTSINK_MAP(CHtmlEditorDlg)
	ON_EVENT(CHtmlEditorDlg, IDC_EXPLORER1, 252 /* NavigateComplete2 */, OnNavigateComplete2Explorer1, VTS_DISPATCH VTS_PVARIANT)
	//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()

void CHtmlEditorDlg::OnNavigateComplete2Explorer1(LPDISPATCH pDisp, VARIANT FAR* URL) 
{
	//let's turn on HTML editing capabilities!
	m_ctrlWeb.SetDesignMode(TRUE);
}

void CHtmlEditorDlg::OnGetHtml() 
{
	CString str;
	m_ctrlWeb.GetDocumentHTML(str);
	AfxMessageBox(str);
}

void CHtmlEditorDlg::OnBold() 
{
	m_ctrlWeb.Bold();
}

void CHtmlEditorDlg::OnItalic() 
{
	m_ctrlWeb.Italic();
}

void CHtmlEditorDlg::OnUnderline() 
{
	m_ctrlWeb.Underline();	
}

void CHtmlEditorDlg::OnImage() 
{
	m_ctrlWeb.Image();	
}

void CHtmlEditorDlg::OnHyperlink() 
{
	m_ctrlWeb.HyperLink();	
}

void CHtmlEditorDlg::OnUndo() 
{
	m_ctrlWeb.Undo();	
}

void CHtmlEditorDlg::OnRedo() 
{
	m_ctrlWeb.Redo();	
}

void CHtmlEditorDlg::OnSource() 
{
	m_ctrlWeb.ShowSource();	
}

void CHtmlEditorDlg::OnTh() 
{
	ShellExecute(NULL, "open", "http://www.trayhelper.com/indexeng.html", "","",SW_SHOW);
}

⌨️ 快捷键说明

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