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

📄 vb0104.htm

📁 关于VB控件的学习和一些使用方法
💻 HTM
字号:
<HTML>
<head><title>洪恩在线 - 在状态栏中显示帮助信息</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<META HTTP-EQUIV="Pragma" CONTENT="no_cache">

<link rel="stylesheet" href="/pub/css/home.css">
<link rel="stylesheet" href="/pc/program/program.css">
<meta name="keywords" content="程序设计,趣味编程,源码,源程序,源码讲解,状态栏,在状态栏中显示帮助信息,statusbar,panels,教程,电脑,教育,电脑乐园,交互">
<script language="javascript">
<!--
function change(myform)
{
        var url="www.hongen.com/pc/program/index.htm";
        url=myform.select.options[myform.select.options.selectedIndex].value;
        top.location.href=url;
}
//-->
</script></head>
<body bgcolor="white" text="black" topmargin="10" leftmargin="0" marginwidth="0" marginheight="10">
<!--顶部开始--><script language=javascript src=/pub/js/head.js></script><!--顶部结束--> 
<table width="760" height="20" border=0 cellspacing="0" cellpadding="0" align="center">
  <tr valign="middle" align="left"> 
    <td height=20 class="p1" width="297" bgcolor="#D3E7FF" align=center><div align="left">   <a href="/pc/program/index.htm" class=under>程序设计栏目首页</a></div></td>
    <td align=left class="p1" height="20" width="58" valign="top"><img src="/pc/program/img/leftnew-0.gif" width="52" height="20"></td>
    <td align="right" class="p1" height="20" width="405"><font color="#330099">当前位置:<a href="/default.htm" class="under">洪恩在线</a> 
      -&gt; <a href="/pc/index.htm" class="under">电脑乐园</a> -&gt; 在状态栏中显示帮助信息</font><img name="image2" src="/pc/img/blank.gif" width="8" height="8"> 
    </td>
  </tr>
</table>
<table width=760 border=0 align="center" cellspacing="0" cellpadding="0">
  <tr>
    <td height=15><img src="/pc/img/blank.gif" width="1" height="1" border=0></td>
  </tr>
</table>
 
<table width="760" border="0" cellspacing="0" cellpadding="0" align="center" height="909">
  <tr> 
    <th width="150" bgcolor="6082CF" align="center" height="910" valign="top">      <!-- 左边条开始 --> 
      <script language="Javascript" src="/pc/program/js/proleft.js"></script>
      <!-- 左边条结束 --><p align="center" class=p1> <a href=/pc/bin/msg.pl?file_id=k_tutor_vb target="_blank"><img src="/pc/img/message.gif" width="64" height="54" alt="请您留言" border="0"><br> 谈谈您的看法</a> 
        <br>
        <script language="javascript">
speak_num="za"
</script>
        <script language="javascript" src=/pc/var/pc_k_tutor_vb.js>
</script>
        <script language="javascript">
var num=0
if (!isNaN(speak_num)){
	num=speak_num;
}
else{
	num=0
}
document.writeln ("已有")
document.writeln (num)
document.writeln ("条发言")
</script>
</p>
      <br>
    </th>
    <td bgcolor="#000000" width="1" height="910"><img src="img/blank.gif" width="1" height="1"></td>
    <td valign="top" align="center" height="910"> <br>
      <table width="95%" border="0" cellspacing="0" cellpadding="0">
        <tr> 
          <td>&nbsp;</td>
          <td width="13" valign="middle"><img src="/pc/program/img/dot.gif" width="13" height="13"></td>
          <td class="p2" width="150" align="center" valign="middle"><font color="B85959"><b>编 
            程 入 门</b></font></td>
          <td width="179"><img src="/pc/program/img/logo2.gif" width="179" height="52"></td>
        </tr>
      </table>
      <table width="95%" border="0" cellspacing="0" cellpadding="0" class="p2">
        <tr> 
          <td height="15" valign="bottom" colspan="3" class="p2">--看实例学VB6.0--<b>在状态栏中显示帮助信息--</b></td>
          <td height="15" valign="bottom" class="p2" width="23%"> 
            <div align="right" class="p1"><a href="/pc/program/tutors/vb/vb0105.htm">下一节</a></div>
          </td>
        </tr>
        <tr> 
          <td bgcolor="FF9700" height="1" width="4%"><img src="img/blank.gif" width="1" height="2"></td>
          <td bgcolor="FF9700" height="1" width="4%"><img src="img/blank.gif" width="1" height="2"></td>
          <td bgcolor="FF9700" height="1" width="69%"><img src="img/blank.gif" width="1" height="2"></td>
          <td bgcolor="FF9700" height="1" width="23%"><img src="img/blank.gif" width="1" height="2"></td>
        </tr>
</table>
      <table width="95%" border="0" cellspacing="0" cellpadding="0" class="p2" background="../../../img/line.gif">
        <tr align="center"> 
          <td class="p2" height="120" colspan="4"> 
            <p align="left"><span class="p2" style="line-height:17pt">  状态栏是VB中的一个很有用的控件,但是默认状态下它不在控件面板中,在我们使用它之前必须先添加,方法是按下Ctrl+T快捷键,在弹出的“Components”对话框中选中MS 
              Windows Common Controls。这时在控件面板中会出现状态栏的小图标<img src="img/statusbar.gif" width="28" height="28" align="absmiddle" alt="状态栏图标">,双击此图标就能把它添加到窗体中。</span></p>
            <p align="center"><img src="img/panels.gif" width="419" height="334" alt="属性编辑框"></p>
            <p align="left"><span class="p2" style="line-height:17pt">  接下来我们根据自己的需要来编辑状态栏,选中窗体上的状态栏,在鼠标右键菜单中选择“属性Properties”,这时会弹出如上图所示的对话框,我们选择“Panels窗格”。其中“Insert 
              Panel”按钮用来添加状态栏中的窗格数目,当我们添加一个窗格后“Index”的值也会自动加一,在程序中我们通过窗格的索引值来引用窗格。下面的一些项目都是窗格的属性,我们可以在此设置也可在程序中控制它。比较常用的属性有:<br>
                “Text”--在各个窗格中显示的文字;<br>
                “Alignment”--窗格中文本的对齐方式;<br>
                “Style”窗格的样式(选择0-sbrText为显示文本,选择6-sbrDate为显示日期等等);<br>
                “Bevel”--窗格的凹凸状态。<br>
                另外我们还可以在窗格中加入图片,方法是点击“Browse”然后选中图片文件。</span></p>
            <p align="left"><span class="p2" style="line-height:17pt">  在本程序中我们在第一个窗格中动态显示帮助信息,在第二、三个窗格中分别显示日期和时间。那么怎样在程序中控制状态栏中显示的文本呢?</span></p>
            <p align="left"><span class="p2" style="line-height:17pt">  例如我们希望鼠标移动到不同的按钮上时状态栏的第一个窗格中显示不同的帮助,则我们在按钮的OnMouseOver事件中加入如下语句即可:<br>
              <span class="p1"> Private Sub CmdNew_MouseMove(Button As Integer, 
              Shift As Integer, X As Single, Y As Single) <br>
                 staSample.Panels(1).Text = "" <br>
                 staSample.Panels(1).Text = "清空文本框" <br>
               End Sub </span></span></p>
            <p align="left"><span class="p2" style="line-height:17pt">  同样的我们能为其它按钮等控件添加帮助信息。</span></p>
            <p align="left"><span class="p2" style="line-height:17pt">  为了学习方便,提供的源码已经作了详细的中文注释,看看源码框中的代码:</span></p>
            <div align="center"> 
              <p> 
                <textarea name="textfield" cols="80" rows="7" onMouseOver="this.focus()" onFocus="this.select()" readonly>'--------------------------------------
'        一个使用StatusBar的例子
'--------------------------------------
'           洪恩在线 求知无限
'--------------------------------------
'------名称-------------作用------------
'      CmdItalic        “斜体”按钮
'      CmdBold          “粗体”按钮
'      CmdExit          “退出”按钮
'      CmdNew           “重写”按钮
'      Text1             文本框
'      frmStatusBar      主窗体
'      staSample         状态栏
'--------------------------------------
Option Explicit

'当“斜体”按钮按下时
Private Sub CmdItalic_Click()
'将文本框中的字体设为斜体
Text1.FontItalic = True
End Sub

'当鼠标移动到“斜体”按钮上时
Private Sub CmdItalic_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'把状态栏的第一个Panels中的Text属性设为&quot;转化为斜体&quot;的帮助信息
staSample.Panels(1).Text = &quot;&quot;
staSample.Panels(1).Text = &quot;转化为斜体&quot;
End Sub

'当“粗体”按钮按下时
Private Sub CmdBold_Click()
'将文本框中的字体设为粗体
Text1.FontBold = True
End Sub

'当鼠标移动到“粗体”按钮上时
Private Sub CmdBold_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'把状态栏的第一个Panels中的Text属性设为&quot;转化为粗体&quot;的帮助信息
staSample.Panels(1).Text = &quot;&quot;
staSample.Panels(1).Text = &quot;转化为粗体&quot;
End Sub

'当“退出”按钮按下时
Private Sub CmdExit_Click()
'退出程序
Unload Me
End Sub

'当鼠标移动到“退出”按钮上时
Private Sub CmdExit_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'把状态栏的第一个Panels中的Text属性设为&quot;退出程序&quot;的帮助信息
staSample.Panels(1).Text = &quot;&quot;
staSample.Panels(1).Text = &quot;退出程序&quot;
End Sub

'当“重写”按钮按下时
Private Sub CmdNew_Click()
'将文本框中的文本清空
Text1.Text = &quot;&quot;
Text1.FontBold = False
Text1.FontItalic = False
End Sub

'当鼠标移动到“重写”按钮上时
Private Sub CmdNew_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'把状态栏的第一个Panels中的Text属性设为&quot;清空文本框&quot;的帮助信息
staSample.Panels(1).Text = &quot;&quot;
staSample.Panels(1).Text = &quot;清空文本框&quot;
End Sub

Private Sub edit_Click()
frmProperties.Show vbModal
End Sub

'当鼠标移动到文本框上时
Private Sub Text1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'把状态栏的第一个Panels中的Text属性设为&quot;输入文字&quot;的帮助信息
staSample.Panels(1).Text = &quot;&quot;
staSample.Panels(1).Text = &quot;输入文字&quot;
End Sub
</textarea>
                <br>
                (<a href="/pc/program/tutors/vb/zip/vb0103.zip">源程序下载</a>)</p>
              <p align="left"><span class="p2" style="line-height:17pt">  这样状态栏中就能动态显示帮助信息了。</span></p>
            </div>
            </td>
        </tr>
        <tr> 
          <td bgcolor="FF9700" height="2" width="5%"><img src="img/blank.gif" width="1" height="2"></td>
          <td bgcolor="FF9700" height="2" width="5%"><img src="img/blank.gif" width="1" height="2"></td>
          <td bgcolor="FF9700" height="2" width="29%"><img src="img/blank.gif" width="1" height="2"></td>
          <td bgcolor="FF9700" height="2" width="61%"><img src="img/blank.gif" width="1" height="2"></td>
        </tr>
      </table>
      
      <table width="95%" align="center" class="p1" border="0" cellpadding="0" cellspacing="0">
        <tr> 
          <td width="16%"> 
            <div align="center"><a href="/pc/program/index.htm">程序设计首页</a></div>
          </td>
          <td width="16%"> 
            <div align="center"><a href="/pc/program/tutors/index.htm" color="#009999">编程入门首页</a></div>
          </td>
          <td width="41%"> 
            <div align="left">相关链接:   <a href="/pc/program/codtutor/index.htm">VB趣味程序讲解</a></div>
          </td>
          <td width="16%"> 
            <div align="right"><a href="/pc/program/tutors/vb/vb0103.htm">上一节</a>  <a href="/pc/program/tutors/vb/vb0105.htm">下一节</a></div>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<!--底部开始--> 
<script language="Javascript" src="/pub/js/foot.js"></script>
<!--底部结束--></HTML>

⌨️ 快捷键说明

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