bsp; ERROR_BAD_FORMAT: ShowMessage( ''The .EXE file is invalid
(non-Win32 .EXE or error in .EXE image'');
SE_ERR_ACCESSDENIED: ShowMessage( ''The operating system
denied access to the specified file.'');
SE_ERR_ASSOCINCOMPLETE: ShowMessage( ''The filename
association is incomplete or invalid.'');
SE_ERR_DDEBUSY: ShowMessage( ''The DDE transaction
could not be completed because other DDE transactions
were being processed.'');
SE_ERR_DDEFAIL: ShowMessage( ''The DDE transaction failed.'');
SE_ERR_DDETIMEOUT: ShowMessage( ''The DDE transaction
could not be completed because the request timed out.'');
SE_ERR_DLLNOTFOUND: ShowMessage( ''The specified
dynamic-link library was not found.'');
SE_ERR_FNF: ShowMessage( ''The specified file was not found.'');
SE_ERR_NOASSOC: ShowMessage( ''There is no application
associated with the given filename extension.'');
SE_ERR_OOM: ShowMessage( ''There was not enough
memory to complete the operation.'');
SE_ERR_PNF: ShowMessage( ''The specified path was not found.'');
SE_ERR_SHARE: ShowMessage( ''A sharing violation occurred.'');
else
if(RtnValue < =32) then ShowMessage( ''Unknown
Error in ShellExecte.'');
end;
Result := RtnValue;
end;
procedure Register;
begin
RegisterComponents(''Tools'', [THyperLink]);
end;
end.
由于THyperLink内部使用ShellExcute函数来打开网页,而ShellExcute函数的特点是可调用与给定文件相关联的应用程来打开该文件,所以在属性URL中设置其它类型的文件(如E-mail地址、文本文件、图像文件,甚至是数据库文件),只要用户的
计算机内有相应程序,ThyperLink就能打开该文件。不过E-mail地址应写成mailto:1234@5678.com这样的型式。以下是一简单的示例
程序:
unit sample;
interface
uses
Windows, Messages, SysUtils, Classes,
Graphics, Controls, Forms, Dialogs,
Menus, StdCtrls, HyperLink;
type
TForm1 = class(TForm)
HyperLink1: THyperLink;
MainMenu1: TMainMenu;
Help1: TMenuItem;
BorlandHomePage1: TMenuItem;
procedure BorlandHomePage1Click(Sender: TObject);
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.BorlandHomePage1Click(Sender: TObject);
begin
HyperLink1.Browse(''http://www.borland.com'');
end;
end.
因为ThyperLink组件的父类是TCustomLabel组件,所以它拥有TCustomLabel的全部属性、方法、事件,这就是说如果需要的话,你可直接使用它们。