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

📄 dpi10.htm

📁 delphi 教程 Delphi 6 常见的大部分函数的使用方法及使用例子
💻 HTM
字号:
<html>
<head>
<title>自动隐藏的声像按钮</title>
 
 
 
 
 
<meta content="text/html; charset=gb2312" http-equiv=Content-Type>
 
 
</head>
<p align="center"><script src="../../1.js"></script></a>

<body bgcolor="#ffffff" leftmargin="5" topmargin="1" marginheight="5" marginwidth="5">
<div align=center> 
  <table border=0 cellpadding=0 cellspacing=0 width=680 align="center">
    <tbody> 
    <tr> 
       
    </tr>
    </tbody> 
  </table>
  <table border=0 bordercolordark=#66aaff bordercolorlight=#66aaff cellpadding=0 
cellspacing=0 width=680 align="center" height="128">
    <tbody> 
    <tr> 
      <td bgcolor=#F9D23C height=14> 
        <div align=center class=H1> <big>自动隐藏的声像按钮</big> </font></b></font></b></font></div>
      </td>
    </tr>
    <tr valign=top> 
      <td class=H1 height=236> 
        <p align="center">&nbsp;</p>
        <p>  随着计算机的日益普及和多媒体技术的不断发展,多媒体计算机辅助教学(MCAI)软件正改变人们传统的学习方式。MCAI软件的操作界面赏心悦目,特别是具有音响效果且能自动隐藏的图像按钮或菜单,图文声并茂,确实为软件添色不少,深受用户喜爱。以下介绍用Delphi实现上述功能的技术。<br>
          <strong>  准备工作<br>
          </strong>  建好应用软件主目录C:\AutoHide及其子目录Images和Sounds。作为软件主界面的背景图像的位图文件Background.bmp,及作为按钮图像的位图Chimera.bmp都存入Images目录中。将声音文件Growl.wav存入Sounds目录。<br>
            BackgroundImage的Picture属性装入Background.bmp,PictureImage的Picture属性装入  Chimera.bmp。ButtonImage重叠于PictureImage之上,置于背景图像的特定位置。<br>
          <strong>  图像按钮<br>
          </strong>  1. 启动Delphi 3.0 IDE,新建项目AutoHide.dpr,主窗体单元命名为Main.pas,存入C:\AutoHide目录。在主窗体上放入三个TImage组件,主要属性按表1设置。<br>
            表1 主窗体和各组件属性设置</p>
        <table border="1" height="296" width="500">
          <tbody> 
          <tr> 
            <td height="17" width="33%" style="font-size: 9pt">组 件</td>
            <td height="17" width="33%" style="font-size: 9pt">组 件</td>
            <td height="17" width="34%" style="font-size: 9pt">设 置</td>
          </tr>
          <tr> 
            <td height="34" width="33%" style="font-size: 9pt">Form1</td>
            <td height="34" width="33%" style="font-size: 9pt">Caption<br>
              Name</td>
            <td height="34" width="34%" style="font-size: 9pt">Auto Hide Button<br>
              MainForm</td>
          </tr>
          <tr> 
            <td height="85" width="33%" style="font-size: 9pt">Image1</td>
            <td height="85" width="33%" style="font-size: 9pt">Align<br>
              Name<br>
              Picture<br>
              Stretch<br>
              Visible</td>
            <td height="85" width="34%" style="font-size: 9pt">alClient<br>
              BackgroundImage<br>
              (TBitmap)<br>
              True<br>
              True</td>
          </tr>
          <tr> 
            <td height="115" width="33%" style="font-size: 9pt">Image2<br>
              <br>
              <br>
              <br>
              <br>
            </td>
            <td height="115" width="33%" style="font-size: 9pt">Align<br>
              Name<br>
              Picture<br>
              Stretch<br>
              Transparent<br>
              Visible</td>
            <td height="115" width="34%" style="font-size: 9pt">alNone<br>
              PictureImage<br>
              (TBitmap)<br>
              True<br>
              True<br>
              True<br>
              False<br>
            </td>
          </tr>
          <tr> 
            <td height="15" width="33%" style="font-size: 9pt">Image3<br>
              <br>
              <br>
              <br>
              <br>
            </td>
            <td height="15" width="33%" style="font-size: 9pt">Align<br>
              Cursor<br>
              Name<br>
              Picture<br>
              Stretch<br>
            </td>
            <td height="15" width="34%" style="font-size: 9pt">alNone<br>
              crHandPoint<br>
              ButtonImage<br>
              (None)<br>
              False<br>
            </td>
          </tr>
          </tbody> 
        </table>
        <p>  2. 建立ButtonImage的OnMouseMove事件,当鼠标移至其上时PictureImage显现:<br>
            PictureImage.Visible:=True;<br>
          <img alt="T69.jpg (15322 字节)" src="../pic/ll/T69.jpg" tppabs="http://www.pcbyte.net/program/T69.jpg" width="227" height="172"></p>
        <p>  3. 建立BackgroundImage的OnMouseMove事件,当鼠标移开ButtonImage时PictureImage隐藏:<br>
            PictureImage.Visible:=False;<br>
            4. 创建ButtonImage(注意:不是PictureImage)的OnClick事件,以响应鼠标点击完成规定动 作。不失一般性,在此仅显示一行信息。<br>
            MessageBeep($FFFF);<br>
            ShowMessage('Welcome to the Delphi.');<br>
            5. 编译、运行。软件启动后进入主界面,在背景图像上没有菜单,也没有按钮,如图1所示。<br>
            当鼠标移至猎豹头部时,豹头变成狮头按钮,且鼠标变为手指,如图2所示。<br>
            当鼠标移出狮头范围时,狮头隐藏,恢复主界面图像。若点击狮头按钮,则出现信息窗(见图3):<br>
            Welcome to the Delphil.<br>
          <img alt="T70.jpg (14719 字节)" src="../pic/ll/T70.jpg" tppabs="http://www.pcbyte.net/program/T70.jpg" width="227" height="172"></p>
        <p><strong>  音响效果<br>
          </strong>  如果要在上述“自动隐藏”按钮加上音响效果,可以在狮头出现时利用PlaySound()播放一个声音文件(.wav)。<br>
            但是,不能将PlaySound()直接加入ButtonImage的OnMouseMove事件中。这是因为,当鼠标在按钮上移动时,PlaySound()会不断重复执行。务必确保按钮出现时声音文件只播放一次!须如此这般:<br>
            1. 为调用PlaySound()函数,并控制声音文件的播放次数,在Main.pas单元的implementation段加入:<br>
            uses<br>
            mmsystem;<br>
            var<br>
            noHide: Boolean;<br>
          <img alt="T71.jpg (13796 字节)" src="../pic/ll/T71.jpg" tppabs="http://www.pcbyte.net/program/T71.jpg" width="227" height="172"></p>
        <p>  2. 创建主窗体MainFrom的OnCreate事件处理程序,以初始化noHide变量:<br>
            noHide:=True;<br>
            3. 将ButtonImage的OnMouseMove事件处理程序(Begin与End之间的语句)改为:<br>
            if noHide then<br>
            begin<br>
            PictureImage.Visible:=True;<br>
            PlaySound('Sounds\Growl',0,SND_ASYNC);<br>
            noHide:=False;<br>
            end;<br>
            4. 将BackgroundImage的OnMouseMove事件处理程序(begin与end之间的语句)改为:<br>
            PictureImage.Visible:=False;<br>
            noHide:=True;<br>
            重新编译和运行。此时,当鼠标移至猎豹头部时,张牙舞爪、咆哮着的狮头闪现,惊心动魄。<br>
            以上例程编译和运行环境是Delphi 3.和中文Windows 98。(海南大学 叶斗彪 570228)
        <p align="center"><font 
      color=#ffa000><b><br>
          </b><b>                                            
      </td>
    </tr>
    </tbody> 
  </table>
</div>
<p align="center"><script src="../../2.js"></script></a>
</body>
</html>

⌨️ 快捷键说明

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