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

📄 delp004.html

📁 对于学习很有帮助
💻 HTML
字号:
<html><!-- #BeginTemplate "/Templates/fwolf001.dwt" -->
<head>
<!-- #BeginEditable "doctitle" --> 
<title>Delphi 5快速创建控制面板程序</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<!-- #EndEditable --> 
<style type="text/css">
<!--
body {  font-family: "宋体"; font-size: 9pt}
td {  font-family: "宋体"; font-size: 9pt}
a:hover {  text-decoration: underline}
a {  text-decoration: none}
input {  font-family: "宋体"; font-size: 9pt}
select {  font-family: "宋体"; font-size: 9pt}
-->
</style>
</head>


<body>
<!-- #BeginEditable "2%C7%F8" --><!-- #EndEditable -->
<div align="left">
  <table width="98%" border="0" align="center">
    <tr> 
      <td width="33%"><a href="../../../index.html"><img src="../../../logos/fwolf9.gif" width="271" height="60" alt="独孤之所首页" border="0"></a></td>
      <td width="67%"> 
        <div align="center"> </div>
      </td>
    </tr>
  </table>
  
</div>
<table width="100%" border="0" align="center" cellspacing="1" bgcolor="#66FF66">
  <tr> 
    <td width="90%"><a href="../../../index2.html">独孤之所</a> > </td>
    <td width="10%"> 
      <div align="center"><a href="javascript:window.close()">[关闭窗口]</a></div>
    </td>
  </tr>
</table>
<hr size="1">
<!-- #BeginEditable "old%20data" --><!-- #EndEditable --> <br>
<table width="584" border="0" align="center" cellspacing="1">
  <tr> 
    <td width="582"> <font color="#FF3333"> 
      <div align="center"><!-- #BeginEditable "%B1%EA%CC%E2" --> <!-- #EndEditable --></div>
      </font> </td>
  </tr>
  <tr> 
    <td width="582"> 
      <div align="center"><!-- #BeginEditable "%D7%F7%D5%DF" --><!-- #EndEditable --></div>
    </td>
  </tr>
  <tr> 
    <td width="582"><!-- #BeginEditable "%CE%C4%B1%BE%C7%F8" --> 
      <center>
        <font color="#FF3333">Delphi 5快速创建控制面板程序</font><font color="#0000c0"><br>
        </font>西安交通大学 <br>
        刘明华 
      </center>
      <p><font color="#ffffff">----</font> Borland Delphi是深受广大软件开发人员喜爱的一种高效、快速的RAD(Rapid 
        Application Development)开发工具。在1999年秋季发布的Delphi 5中,Delphi又引入了许多新的特色。其中之一便是Delphi 
        5的Enterprise和Professional版本中新增了用于快速创建控制面板(CPL)程序的向导和类,这使得我们能够在可视化开发环境中非常方便地建立控制面板应用程序。 
      <p><font color="#ffffff">----</font> <b>一、关于控制面板程序</b> 
      <p><font color="#ffffff">----</font> 在Windows中,用户通过控制面板来进行增删程序、添加硬件、设置各种系统属性等操作。控制面板中所显示的小程序(或称之为对话框)是由控制面板程序(Control 
        Panel Application)提供的。Windows本身附带了十来个控制面板应用程序,它们都位于Windows的System目录下,扩展名为*.CPL。每个控制面板中的应用程序可以有一个或多个对话框,每个对话框在控制面板中用一个图标代表。 
      <p><font color="#ffffff">----</font> 控制面板应用程序实质上是一类特殊的动态链接库,每个控制面板程序必须输出一个CPlApplet函数,它是控制面板应用程序的入口,其主要作用是处理Windows消息。CPlApplet函数的原型为: 
      <pre>
function CPlApplet(
hwndCPl: THandle; //Identifies the main
 window of the controlling application.
uMsg: DWORD; // Specifies the message 
being sent to the Control Panel application
lParam1, lParam2: Longint // Specify
 additional message-specific information
): Longint; stdcall;
</pre>
      <font color="#ffffff">----</font> CplApplet函数是控制面板与控制面板应用程序通讯的唯一方式。一个控制面板程序中的CplApplet函数的基本框架结构如下: 
      <pre>
function CPlApplet(hwndCPl: THandle; uMsg: DWORD;
  lParam1, lParam2: Longint): Longint;
begin
  //…
  case (uMsg) of
    CPL_INIT: begin {…} end;
    CPL_GETCOUNT: begin {…} end;
    CPL_INQUIRE: begin {…} end;
    CPL_NEWINQUIRE: begin {…} end;
    CPL_DBLCLK: begin {…} end;
    CPL_STOP: begin {…} end;
    CPL_EXIT: begin {…} end;
    CPL_STARTWPARMS: begin {…} end;
    CPL_SETUP: begin {…} end;
  end;
//函数的返回值取决于uMsg
end;
</pre>
      <font color="#ffffff">----</font> 事实上,编写控制面板程序的主要任务都放在处理这些CPL_消息上,关于这些消息的含义,请参看Delphi 
      5所带的帮助文档Win32.hlp。 
      <p><font color="#ffffff">----</font> 为了简化控制面板程序的创建,Delphi 5新增了一个可视化构件库CtlPanel.PAS。CtlPanel单元中定义了TAppletApplication(控制面板应用程序类)和TAppletModule类. 
      <p><font color="#ffffff">----</font> 使用TAppletApplication和TAppletModule类构造控制面板应用程序是一件非常轻松的事情。下面我来介绍一下在Delphi 
        5中创建控制面板程序的基本步骤。 
      <p><font color="#ffffff">----</font> <b>二、Delphi 5中建立控制面板程序</b> 
      <p><font color="#ffffff">----</font> 第一步:选择File | New菜单,在New Items对话框的New页上选择Control 
        Panel Application,Delphi将创建一个新的控制面板应用程序(其中已经包含一个applet)。Delphi向导创建的工程文件如下: 
      <pre>
library Project1;
uses
  CtlPanel,
  Unit1 in 'Unit1.pas' 
{AppletModule1: TAppletModule};

exports CPlApplet;

{$R *.RES}
{$E cpl}

begin
  Application.Initialize;
  Application.CreateForm
(TAppletModule1, AppletModule1);
  Application.Run;
end.
</pre>
      <font color="#ffffff">----</font> 在上面的DPR文件中,Application对象的类型是TAppletApplication,而不是TApplication,它是在CtlPanel单元中申明的。而且CplApplet函数也已经由CtlPanel单元定义好了。 
      <p><font color="#ffffff">----</font> 第二步:更改AppletModule的属性 
      <p><font color="#ffffff">----</font> 一个AppletModule对象代表一个对话框(即applet),一个CPL应用程序可以包含多个对话框。你可以通过Delphi向导来增添多个AppletModule。 
      <p><font color="#ffffff">----</font> AppletIcon属性:指定一个图标,此图标将出现在控制面板中。 
      <p><font color="#ffffff">----</font> Caption属性:显示在图标下面的文字。 
      <p><font color="#ffffff">----</font> Help属性:出现在控制面板窗口的状态栏上的文字。 
      <p><font color="#ffffff">----</font> ResidIcon属性:图标资源id,此属性与AppletIcon属性互斥。 
      <p><font color="#ffffff">----</font> ResidName属性:字符串资源id,此属性与Caption属性互斥。 
      <p><font color="#ffffff">----</font> ResidInfo属性:字符串资源id,此属性与Help属性互斥。 
      <p><font color="#ffffff">----</font> 第三步:编写事件句柄 
      <p><font color="#ffffff">----</font> 在控制面板中,当鼠标双击对话框的图标时,相应的AppletModule对象会产生OnActivate事件。为了响应鼠标的双击,你需要为TAppletModule的OnActivate事件属性提供一个事件句柄。 
      <pre>

procedure TAppletModule1.
AppletModuleActivate(Sender: 
                  TObject; Data: Integer);
begin
  MessageBox(Application.ControlPanelHandle, 
             'Delphi 5 is so great!', 'CPL Demo',
               MB_ICONINFORMATION);
end;
</pre>
      <font color="#ffffff">----</font> 第四步:CPL的安装 
      <p><font color="#ffffff">----</font> 由于动态连接库工程文件中有一个{$E cpl}编译指示字,编译此DPR文件将产生一个扩展名为.CPL的文件,它就是我们所要的控制面板应用程序模块。控制面板程序的安装十分简单,只要将CPL文件拷贝到Windows的System目录(或者Windows 
        NT的System32目录)下即可。当你再次打开控制面板时,你所编写的控制面板应用程序就会出现。 
      <!-- #EndEditable --></td>
  </tr>
  <tr>
    <td width="582"><!-- #BeginEditable "%B1%B8%D7%A2" --><!-- #EndEditable --></td>
  </tr>
</table>
<br>
<hr size="1">
<table width="25%" border="1" align="center" cellspacing="0" cellpadding="0" bordercolorlight="#CCCCFF" bordercolordark="#000033" bordercolor="#6666FF">
  <tr align="center"> 
    <td> 转载请注明出于 <a href="http://fwolf.yeah.net" target="_blank">独孤之所</a><!--Fwolf出品
fwolf001@163.net
http://fwolf.yeah.net --> </td>
  </tr>
  <tr align="center"> 
    <td> 
      <script>document.write("<a href=http://www.topcn.com/siteinfo.asp?UserName=fwolf2000&SiteType=0 target=_blank><img src=http://www1.topcn.com:8081/statistics.asp?fwolf2000&referURL="+escape(top.document.referrer)+"&curURL="+escape(top.document.URL)+"&imgStyle=0"+" border=0 alt='Top中文网站龙虎榜' ></a>");</script>
      <script>document.write("<a href=http://www.textclick.com/viewmain.asp?name=fwolf2000 target=_blank><img src=http://ad.t2t2.com/stat.asp?user=fwolf2000&refer="+escape(document.referrer)+"&cur="+escape(document.URL)+" alt=太极统计 border=0></a>");</script>
    </td>
  </tr>
</table>
<table width="100%" border="0" align="center" cellspacing="1" bgcolor="#66FF66">
  <tr> 
    <td width="10%"><a href="javascript:window.close()">[关闭窗口]</a></td>
    <td width="90%"> 
      <div align="left"></div>
    </td>
  </tr>
</table>
<div id="Layer1" style="position:absolute; width:470px; height:60; z-index:1; left: 293px; top: 13px; overflow: hidden"> 
  <table width="100%" border="0" cellspacing="0" cellpadding="0" height="60">
    <tr> 
      <td><a href="http://202.99.67.100/adclick2/click/random.cgi?job=go&id=1490" target="_blank"><img src="http://202.99.67.100/adclick2/click/random.cgi?id=1490" border="0" width="468" height="60"></a> 
      </td>
    </tr>
  </table>
</div>
<div align="center"></div>
<p align="center"> 
<script language="JavaScript1.1" src=http://ad.t2t2.com/textclick.asp?user=fwolf&style=4&bkcolor=no></script>
</p>
<p align="center">&nbsp; </p>
</body>
<!-- #EndTemplate --></html>

⌨️ 快捷键说明

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