我们知道大多数应用程序都有一个“关于”的窗口,在该窗口中是一些关于程序的说明,以及作者介绍联系等。你如果有自己的Internet网站地址,那么就可以让用户直接点击“关于”窗口中的网址,自动调用浏览器与你站点连接,。本文就告诉你地Delphi程序中如何实现该功能。 1. 在你的“关于”窗口中添加一个标签Labell,其属性按如下设置: Label1.Caption www.cfan.cn.net Label1.Cursor crHandPoint Label1.Color clolive 2. 在Labell的OnClick事件中输入以下代码: var TempString:array[0..79] of char; begin StrPCopy(TempString,Labell.Caption); OpenObject(TempString); end; 3. 添加OnClick中的OpenObject过程 procedure TForm1.OpenObject(sObjectPath:PChar); Begin ShellExecute(O,NIl,sObjectPath,Nil,Nil,SW_NORMAL); end; 4. 将ShellAPI添加到Uses中 完整的程序如下: unit Unit1; interface uses Windows,Messages,SysUtils,Classes,Graphics,Controls,Forms,Dialogs, StdCtrls,ShellApi; type TForml=class(TForm) Labell:TLabel; procedure LabellClick(Sender:TObject); procedure OpenObject(sObjectPath:PChar); private {Private declarations} public {Public declarations} end; var Forml:TForml; implementation {$R *.DFM} procedure TForml..LabellClick(Sender:TObject); var TempString:array[0..79] of char; begin StrPCopy(TempString,Labell.Caption); OpenObject(TempString); end; procedure TForm1.OpenObject(sObjectPath:PChar); Begin ShellExecute(O,Nil,sObjectPath,Nil,Nil,SW_NORMAL); end; end. 该程序在Delphi3.0中调试通过
|