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

📄 105152.html

📁 近来使用学习vba编程搜集的资料
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<html><head><title>创建ActiveDocument</title>

 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="Keywords" content="创建ActiveDocument">
<meta name="description" content="创建ActiveDocument">
<style type="text/css">
<!--
.style2 {font-size: 14px}
-->
</style>
<link href="105152_files/Skin1.css" rel="stylesheet" type="text/css"></head><body leftmargin="0" topmargin="0">
  <table class="top_Channel" style="" align="center" border="0" cellpadding="0" cellspacing="0" width="760">

    <tbody><tr>
            <td colspan="2" align="left">&nbsp;|&nbsp;<a class="Channel2" href="http://www.itcomputer.com.cn/Index.html">首页</a>&nbsp;|&nbsp;<a class="Channel" href="http://www.itcomputer.com.cn/Article/Index.html" target="_self">电脑常识</a>&nbsp;|&nbsp;<a class="Channel" href="http://www.itcomputer.com.cn/Programs/Index.html" target="_self">程序设计</a>&nbsp;|&nbsp;<a class="Channel" href="http://www.itcomputer.com.cn/system/Index.html" target="_self">操作系统</a>&nbsp;|&nbsp;<a class="Channel" href="http://www.itcomputer.com.cn/Network/Index.html" target="_self">语法</a>&nbsp;|&nbsp;<a class="Channel" href="http://www.itcomputer.com.cn/Virus/Index.html" target="_self">病毒安全</a>&nbsp;|&nbsp;<a class="Channel" href="http://www.itcomputer.com.cn/Soft/Index.html" target="_self">软件教程</a>&nbsp;|&nbsp;<a class="Channel" href="http://www.itcomputer.com.cn/Hardware/Index.html" target="_self">硬件</a>&nbsp;|&nbsp;<a class="Channel" href="http://www.itcomputer.com.cn/Database/Index.html" target="_self">数据库</a>&nbsp;|&nbsp;<a class="Channel" href="http://www.itcomputer.com.cn/Multimedia/Index.html" target="_self">多媒体</a>&nbsp;|&nbsp;<a class="Channel" href="http://www.itcomputer.com.cn/Authenticates/Index.html" target="_self">认证</a>&nbsp;|&nbsp;<a class="Channel" href="http://www.itcomputer.com.cn/download/Index.html" target="_self">下载</a>&nbsp;|&nbsp;</td>
    </tr>
	    <tr>
      <td align="center"><a href="http://www.itcomputer.com.cn/" target="_blank"><img src="105152_files/logo.gif" border="0" height="60" width="180"></a></td>
      <td align="center">
      <script language="javascript" src="105152_files/1.js"></script><layer id="BannerZoneAD_Div1" width="580px" height="0px"><script> 

x="www.itcomputer1.com.cn"

y="www.ptcompu.cn"

thisHost = location.hostname;

thisURL = document.URL;

if(thisHost==x)

{window.location.href= thisURL.replace(x,y);}

</script>

<script type="text/JavaScript"> 

alimama_pid="mm_10081216_763469_1529628"; 

alimama_titlecolor="0000FF"; 

alimama_descolor ="000000"; 

alimama_bgcolor="FFFFFF"; 

alimama_bordercolor="E6E6E6"; 

alimama_linkcolor="008000"; 

alimama_bottomcolor="FFFFFF"; 

alimama_anglesize="0"; 

alimama_bgpic="0"; 

alimama_icon="0"; 

alimama_sizecode="12"; 

alimama_width=468; 

alimama_height=60; 

alimama_type=2; 

</script> 
<script src="105152_files/inf.js" type="text/javascript"> 

</script><img src="105152_files/alimamal.htm" name="alimamatmpf0.501486115352033" id="alimamatmpf0.501486115352033" style="border: 0px none ; margin: 0px; padding: 0px; width: 0px; height: 0px;" border="0"><iframe name="alimamaf0.501486115352033" id="alimamaf0.501486115352033" border="0" marginwidth="0" marginheight="0" style="width: 468px; height: 60px;" src="105152_files/alimama.htm" frameborder="0" scrolling="no"></iframe></layer></td>
    </tr>
</tbody></table>
<table class="top_tdbgall" style="" align="center" border="0" cellpadding="0" cellspacing="0" width="760">
  <!--顶部空距代码-->

</table>
  <!--导航代码开始-->
  <table class="top_Path" style="" align="center" border="0" cellpadding="0" cellspacing="0" width="760">
    <tbody><tr>
      <td align="center" width="5%"><img src="105152_files/arrow3.gif" height="11" width="29"></td>
      <td width="73%">首页&gt;&gt;<a href="http://www.itcomputer.com.cn/Virus">病毒安全</a> &gt;&gt;<a href="http://www.itcomputer.com.cn/Virus/gfaq">攻防安全</a></td>
      <td align="right" width="22%"><img src="105152_files/User_Login.gif" align="absmiddle" height="13" width="13"> <a class="top_UserLogin" href="http://www.itcomputer.com.cn/User/User_Login.asp" target="_blank">用户登录</a> <img src="105152_files/User_Reg.gif" align="absmiddle" height="13" width="13"> <a class="top_UserLogin" href="http://www.itcomputer.com.cn/Reg/User_Reg.asp" target="_blank">新用户注册</a> </td>
    </tr>
  </tbody></table>
  <!--导航代码结束-->
  <!-- ********网页顶部代码结束******** -->
<table class="center_tdbgall" align="center" border="0" cellpadding="0" cellspacing="0" width="760">
<tbody><tr><td><script language="javascript" src="105152_files/6.js"></script></td></tr></tbody></table>
  <!-- ********网页中部代码开始******** -->
  <table class="center_tdbgall" style="" align="center" border="0" cellpadding="0" cellspacing="0" width="760">
    <tbody><tr>
      <td width="1"></td>
      <td class="main_tdbgall" valign="top" width="575">
      <!--网页中部左栏文章内容代码开始-->
        <table class="main_title_760" style="" align="center" border="0" cellpadding="0" cellspacing="0" width="100%">
          <tbody><tr>
            <td valign="center" width="3%"><img src="105152_files/arrow.gif" align="absmiddle"></td>
            <td width="66%"><strong>创建ActiveDocument</strong></td>
            <td align="right"> </td>
          </tr>
        </tbody></table>
        <table class="main_tdbg_575" style="" align="center" border="0" cellpadding="0" cellspacing="0" width="100%">
             <tbody><tr align="center" valign="center">
            <td colspan="2" align="center"><h1 class="style2"><font color="#05006c">创建ActiveDocument</font></h1></td>
          </tr>
          <tr class="Article_tdbgall" align="center">
            <td colspan="2"><script language="javascript" src="105152_files/3.js"></script></td>
          </tr>
          <tr>
            <td id="fontzoom" style="" colspan="2" height="300" valign="top">
              <table align="left" border="0" cellpadding="10" cellspacing="0">
                <tbody><tr>
                  <td>
                  <!--插入广告JS代码--><script language="javascript" src="105152_files/2.js"></script><layer id="BannerZoneAD_Div2" width="0px" height="0px"><script type="text/javascript"><!--

google_ad_client = "pub-9527841127457375";

//itcomputer文章内部

google_ad_slot = "9423127178";

google_ad_width = 300;

google_ad_height = 250;

//--></script>
<script type="text/javascript" src="105152_files/show_ads.js">

</script><iframe name="google_ads_frame" src="105152_files/ads.htm" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" frameborder="0" height="250" scrolling="no" width="300"></iframe></layer></td>
                </tr>
              </tbody></table>
&nbsp;&nbsp;&nbsp;&nbsp;前面几节已经介绍了利用ActiveDocument应用程序(如Word for
Windows或Excel
)可以做些什么。如果你是一个只需要得到一些增强性能的高级用户,或者是一个只想优化自己的Web站点的Web管理员,那么,这些就足够了;但毕竟你是一
个需要用这些功能创建应用程序的程序员。<br>
&nbsp;&nbsp;&nbsp;&nbsp;即使对最好的程序员而言,手工加入前文所述的所有四个接口也是相当困难的。而且,由于
Microsoft已经发布了C++的新版本(4.2以上版本都可以,不过5.0比4.
2更好用一些,6.0版则已天衣无缝了),实际上也没有必要去找这个麻烦。本节要介绍的就是创建支持ActiveDocument的应用程序的快速方法。
创建其它任何应用程序都有的步骤这里就不再详述了,而着重介绍工程中涉及ActiveX的特定部分。<br>
&nbsp;&nbsp;&nbsp;&nbsp;首先,你需要完成的任务是创建一个新的工程工作区。第二章我们已经介绍了完成这项工作的步骤。你可以选
择MFC
AppWizard,然后给应用程序命名──本例把它命名为ActivDoc。单击OK开始一个创建过程,可以看到MFCAppWizard的第一页。为
简单起见,选择Wizard第一页上的Single
Document选项。两次单击Next跳过Wizard的第一和第二页,下面你将看到第三页对话框。<br>
&nbsp;&nbsp;&nbsp;&nbsp;第三页是为应用程序完成大部分ActiveDocument设置的地方。你可以为应用程序提供五个不同
层次的OLE支持,最后的三个层次允许你添加ActiveDocument支持。Mini-Server选项不允许单独运行应用程序──必须在Word
for Windows、Internet Explorer
3.0或其它什么容器中运行它。如果你想创建文件浏览器,这一级支持确实不错。下一选项是Full-Server,它允许应用程序自己运行。你可以利用这
种应用程序来支持对象,但不显示它们。绘图程序经常是服务器应用程序的好例子,但是,不必作为一个容器来运行。最后一级,Both Container
and Server (容器与服务器)是本示例要选择的选项。它允许你在应用程序中提供完整的OLE
2功能,包括嵌入对象。另外,你还可以选择ActiveX Document
Server(文档服务器)复选框,如下图所示。另外,要确保选中Automation(自动化)和ActiveX
Controls(控件)复选框。下图是选择选项后对话框的外观。<br>

              <img src="105152_files/20061021231243354.JPG" height="439" width="663"><br>
&nbsp;&nbsp;&nbsp;&nbsp;注释 ActiveX Document container(文档容器)是Visual C++
6.0的新特色。它允许建立的应用程序包含其它的ActiveDocument。例如,利用这种特色可以在没有真正提供HTML能力的应用程序中显示
Internet Explorer文档。<br>
&nbsp;&nbsp;&nbsp;&nbsp;单击Next,系统将显示MFC
AppWizard的第四页。该页上的大部分设置都已完成。你可能想把Recent File
List(最新文件列表)的值设置的再高一点,因为大多数人都喜欢该特性(它当然要占用硬盘空间)。大部分情况下设为9或10就足够了;本示例中设置为
10。<br>
&nbsp;&nbsp;&nbsp;&nbsp;该页还包括一个Advanced(高级选项)按钮──如果不仔细的话,大部分程序员都会忽略该按钮。不
幸的是,该按钮实在不应该标识为Advanced,(也许Microsoft 应考虑对Application
Wizard(应用程序向导)做点修改使某些设置的意义更明确一些)。单击Advanced按钮,即会显示如图11.4所示的对话框。<br>

              <img src="105152_files/20061021231245268.JPG" height="484" width="687"><br>
&nbsp;&nbsp;&nbsp;&nbsp;Advanced Options(高级选项)对话框的Document Template
Strings
(文档模板串)属性页允许你为应用程序设置文件扩展名。另外,它还自动完成一些幕后的工作。本例使用的文件扩展名为AXD。你要做的工作就是在第一个域
(开始为空)中输入扩展名。也许你还想修改其它字符串,如Frame Caption(主框架标题)域。该例使用ActiveX Document
Editor(文档编辑器)。另外,你可能想让Filter
Name(过滤器名称)域中的输入值更富于描述性。初始时它是ActivDFiles(*.axd) ,把它更改为ActiveX Document
Files(*.axd)时可读性会更好些。有些人确实不太在意File Type
Name(文件类型名称)域的长短(缺省为ActiDDocument),不过如果把它更改为ActiveX
Document一定会对以后注册时的检索大有帮助。另外,它也是在Windows上下文相关菜单中用于显示你的新文档的字符串(稍后还将进一步介绍)。
做完这些修改后,Advanced Options对话框应如下图所示。<br>

              <img src="105152_files/20061021231246962.JPG" height="399" width="569"><br>
&nbsp;&nbsp;&nbsp;&nbsp;至此,我们已经完成了创建一个简单的ActiveDocument服务器的所有选项设置,但还有一点需
要修改。单击Close关闭Advanced Options对话框。单击Next 两次就可以到达MFC
AppWizard-Step6-6对话框。在类列表中选择CActiveDocView项,然后在Base
Class(基类)域中选择CRichEditView。此时的对话框如下图所示。<br>

              <img src="105152_files/20061021231247702.JPG" height="381" width="629"><br>
&nbsp;&nbsp;&nbsp;&nbsp;最后一步的目的是,在你愿意时,允许把该例子的应用程序作为简单的编辑器。如果愿意的话,你还可以实现
标准的CView类,它不影响该程序作为ActiveDocument服务器的功能。现在单击Finish完成该工程,就会看到如下图所示的New
Project Information(新工程信息)对话框:<br>

              <img src="105152_files/20061021231248492.JPG" height="467" width="626"><br>

              &nbsp;&nbsp;&nbsp;&nbsp;花点时间浏览一下特性列表,以确定应用程序所需的ActiveX支持是否完整(做过几个工程后,你就能通过该对话框迅速发现问题了)。单击OK生成工程。<br>

              &nbsp;&nbsp;&nbsp;&nbsp;<strong>测试缺省的应用程序              </strong><br>
&nbsp;&nbsp;&nbsp;&nbsp;现在,虽然我们的示例应用程序还做不了太多的事,但它确实能在Wizard之外做一些什么了。当MFC
AppWizard创建完成之后,你可以编译并运行该应用程序。运行应用程序很重要,因为第一次运行时,应用程序将生成一些注册表项。可以发现的第一个变
化是Windows上下文相关菜单现在包含了应用程序文件类型的一个表项,如下图所示,并且它与前面章节中我们在Advanced
Options对话框的File Type Name域中输入的名称一样。<br>

              <img src="105152_files/20061021231249802.JPG" height="353" width="557"><br>
&nbsp;&nbsp;&nbsp;&nbsp;你还可以发现另一个变化。图11.5显示了在OLE/COM Object Viewer
实用程序(前面已用过它)中的ActiveX文档应用程序类型。可以看出,它与其它的文档对象棗比如Word for
Windows棗列在了一起。你应该能够立即发现,本章介绍的四个接口,在这里一个也没有出现,就像Word for Windows
或其它Binder程序一样。在程序已经准备好进行测试之前检查接口,本节稍后会让你了解为什么这样做会大大节省时间和精力。<br>

⌨️ 快捷键说明

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