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

📄 ba9.htm

📁 VB教程
💻 HTM
字号:
<HTML>
<HEAD>
<TITLE>由Visual Basic 5.0调用Explorer的方法</TITLE>
 
<META content="text/html; charset=gb2312" http-equiv=Content-Type>
<META content="MSHTML 5.00.2920.0" name=GENERATOR>
 
<meta name="Microsoft Border" content="none, default">
</head>
<p align="center"><script src="../../1.js"></script></a>
<BODY topMargin=4 vLink=#0000ff>
<TABLE border=0 cellPadding=0 cellSpacing=0 width="100%">
  <TBODY>
  <TR>
    <TD height="52"> 
      <DIV align=center>
      <CENTER>
          <table border=0 cellpadding=0 cellspacing=0 width=679 align="center">
            <tbody> 
            <tr> 
              <td width=200 height="59"> 
                 
    </TD></TR><!--msnavigation--></TBODY></TABLE>
<table border=0 cellpadding=0 cellspacing=0 width="100%">
  <tbody> 
  <tr><!--msnavigation--><td valign=top height="235"> 
      <div align=center> 
        <table border=1 bordercolor=#b9d9ff cellpadding=0 cellspacing=0 
      class=table width=755>
          <center>
            <tr> 
               
              <td width="100%" height="3">
                <div align="center"> <strong><b>由Visual 
                  Basic 5.0调用Explorer的方法</b></strong></span></div>
              </td>
            </tr>
            <tr> 
              <td 
            width="100%" class="unnamed1" height="247"> 
                <div align="left"> 
                  <p align="center"><font size="3"><b><br>
                      </font></b></font> <b>一、 
                    简介</b><br>
                      众所周知,Visual Basic 5.0(VB5.0)提供了为实现高级Windows程序所需的完备工具与机制,它的强大功能已被广大软件开发人员所共识;Explorer在当今Internet的迅猛发展中,又起着功不可灭的作用,它处理HTML的身手使每一使用者叹服,如果将VB5.0和Explorer联姻,这不仅仅是锦上添花,而是如虎添翼。从理论上讲,VB5.0为Internet提供了各方面的专门技术,而Explorer又可使用VBScript为其扩展功能,但在具体实施中,编程人员会遇到这样或那样的问题,现在我们给出一个经过调试业已成功的实例,仿照此方法,用户可在自己VB5.0程序的任何地方调用Explore,为使用“帮助文件”或“超级连接”提供方便。<br>
                    <br>
                    <b>二、 实现方法</b><br>
                      首先在VB5.0菜单上选“工程/部件”,然后选Microsoft Internet controls和Microsoft 
                    common Dialog Control 5.0两个控件,使工具栏上增加WebBrowser和Commodialog两个图标,然后在Form1窗体上,如图一所示,引入两个Label,一个Text,三个Command,一个CommoDialog,三个Command的Caption分别为“浏览”、“打开HTM”和“取消”,为书写方便将Commodialog的名字定为cd。<br>
                      在程序中,生成一个InternetExplorer类型的目标ii,通过方法ii.Navigate text1,navNoreadfromcache的调用,使得HTML文件名由text1.text给出,亦即通过Text1给出URL,这样一来,用户不但可通过VB5.0程序自由地开启Explorer窗口,而且URL和窗口的外观也由VB5.0来决定,为了更加清晰,把Explorer的View/options/general中的Standard 
                    Buttons,Address Bar,Links,Text Labels选择去掉。其中,URL可直接输入,也可通过浏览来选择。<br>
                    <br>
                    <b>三、 程序</b><br>
                    Dim ii<br>
                    Private Sub Command1_Click()<br>
                    Cd.Flags = &amp;H200<br>
                    Cd.Filter = &quot;HTML files (*.htm)|*.htm|Text Files&quot; 
                    &amp; _<br>
                    &quot;(*.txt)|*.txt|All Files (*.*)|*.*&quot;<br>
                    Cd.ShowOpen<br>
                    Text1 = Cd.filename<br>
                    Command2.Visible = True<br>
                    End Sub<br>
                    Private Sub Command2_Click()<br>
                    Set ii = GetObject(&quot;&quot;, &quot;INTERNETEXPLORER.APPLICATION&quot;)<br>
                    ii.Navigate Text1, navNoReadFromCache<br>
                    ii.Visible = 1<br>
                    ii.Top = 0<br>
                    ii.Left = 0<br>
                    ii.Width = Form1.Width<br>
                    ii.Height = Screen.Height<br>
                    End Sub<br>
                    Private Sub Command3_Click()<br>
                    Text1 = &quot;&quot;<br>
                    Unload Me<br>
                    End Sub<br>
                    <br>
                    Private Sub Form_Load()<br>
                    Form1.Top = Screen.Height / 4<br>
                    Form1.Left = 0<br>
                    Form1.Width = Screen.Width<br>
                    Form1.Height = Screen.Height / 2<br>
                    Form1.BackColor = QBColor(2)<br>
                    Label1.BackStyle = 0<br>
                    Label1.FontName = &quot;黑体&quot;<br>
                    Label1.FontSize = 14<br>
                    Label1.ForeColor = QBColor(7)<br>
                    Label2.BackStyle = 0<br>
                    Label2.Caption = &quot;H T M L&quot;<br>
                    Label2.FontName = &quot;brush script&quot;<br>
                    Label2.FontSize = 24<br>
                    Command2.Visible = False<br>
                    End Sub<br>
                    Private Sub Text1_KeyPress(KeyAscii As Integer)<br>
                    If KeyAscii = 13 Then<br>
                    Set ii = GetObject(&quot;&quot;, &quot;INTERNETEXPLORER.APPLICATION&quot;)<br>
                    ii.Navigate Text1, navNoReadFromCache<br>
                    ii.Visible = 1<br>
                    ii.Top = 0<br>
                    ii.Left = 0<br>
                    ii.Width = Form1.Width<br>
                    ii.Height = Screen.Height<br>
                    End If<br>
                    End Sub <br>
                    转载自popcool开发专区<b>(文/茅松润)</b> </font> </p>
                  </div>
              </td>
            </tr>
          </center>
          <tr> 
            <td width="100%" class="unnamed1"> 
              <p align=right><a href="ba8.htm">(上一页)</a>---<a href="ba10.htm">(下一页)</a></p>
            </td>
          </tr>
          <tr> 
            <td width="100%" class="unnamed1"> 
               
    </div>
      </td>
  </tr>
  <!--msnavigation--></tbody>
</table>
<p align="center"><script src="../../2.js"></script></a>
</body>
</html>

⌨️ 快捷键说明

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