您的位置:首页 > 编程语言 > C语言/C++

C++中嵌入网页(duilib编辑框的实现)

2012-02-22 13:15 288 查看
效果

View Code

<HorizontalLayout >
<Label text="邮件内容:"  width ="60" height="16" textcolor="#FF666666"/>
<ActiveX name="ie" clsid="{8856F961-340A-11D0-A96B-00C04FD705A2}" delaycreate="false"/>
</HorizontalLayout>


2.加载控件

void CMailDialog::Init() {

SetIcon(IDR_MAINFRAME); //   Set   big   icon

m_pCloseBtn = static_cast<CButtonUI*>(paint_manager_.FindControl(_T("closebtn")));

CActiveXUI* pActiveXUI = static_cast<CActiveXUI*>(paint_manager_.FindControl(_T("ie")));
if( pActiveXUI ) {
IWebBrowser2* pWebBrowser = NULL;
pActiveXUI->GetControl(IID_IWebBrowser2, (void**)&pWebBrowser);
if( pWebBrowser != NULL ) {
std::string strPath=ConfigManager::instance()->getSkinPath()+"\\MailEditor\\index.html";

int Len=::MultiByteToWideChar (CP_ACP, 0, strPath.c_str(), -1, NULL, 0);
wchar_t *buf=new wchar_t [Len];
MultiByteToWideChar(CP_ACP,0,strPath.c_str(),-1,buf,Len);
std::wstring wstrFilePath=std::wstring(buf);
delete[] buf;

pWebBrowser->Navigate((BSTR)(wstrFilePath.c_str()),NULL,NULL,NULL,NULL);
pWebBrowser->Release();
}
}

}


index.html

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta name="save" content="history">
<title>邮件编辑器</title>
<link rel="stylesheet" type="text/css" href="editor/comm.css" />
<script language="javascript" src="editor/all.js"></script>
<script language="javascript" src="editor/editor.js"></script>
<script language="javascript" src="editor/editor_toolbar.js"></script>
<script language="javascript">
function checkform(){
if(document.form1.title.value ==""){
alert("请输入标题");
return false;
}
var v = DoProcess();
if(v != true){
alert("请输入内容");
return false;
}
}
function ReSet()
{
var clientWidth=document.body.clientWidth-10;
var clientHeight=document.body.clientHeight-40;

document.getElementById("HtmlEditor").style.width=clientWidth+'px';
document.getElementById("HtmlEditor").style.height=clientHeight+'px';

var SourceEditorobj=document.getElementById("SourceEditor");
if(SourceEditorobj)
{
SourceEditorobj.style.width=clientWidth+'px';
SourceEditorobj.style.height=clientHeight+'px';
}

}
</script>
<style type="text/css">

.prompt {border:1px dotted #ccc;background-color:#ffe;color:#666;padding: 5px 5px 5px 30px;line-height:120%;width:1600px}
</style>
</head>
<body onResize="ReSet()" scroll= "no" >
<table  border="0" cellpadding="2" cellspacing="1">
<form name="form1" method="post" action="?action=saveadd" target="_blank" onSubmit="return checkform();">

<tr>

<td><textarea id="content" name="content" style="display:none;"></textarea>
<script language="javascript">

gFrame = 0;//1-在框架中使用编辑器
gContentId = "content";//要载入内容的content ID
OutputEditorLoading();
</script>
<iframe id="HtmlEditor" class="editor_frame" frameborder="0" marginheight="0" marginwidth="0" style="width:100%;height:100%;overflow:visible;" hideFocus></iframe>
</td>
</tr>
</form>
</table>
</body>
</html>


editor可以从网上下载
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: