"SysLink"를 서브클래싱해서 사용 가능한 방법이 있어 소개하기는 하지만, 아무래도 Delphi2009 이상에서의 TLinkLabel에 비해 부족한건 사실.... -_-;;;; 좀더 좋은 방법이 없으려나..? 고민을 해봐야겠다.
사용법 #1]
function CreateSysLink(hDlg: HWND; hInst: THandle; rect: TRECT): HWND; begin Result := CreateWindowEx(WS_EX_TRANSPARENT, WC_LINK, 'For more information, <A HREF="http://www.microsoft.com">click here</A> ' + 'or <A ID="idInfo">here</A>.', WS_VISIBLE or WS_CHILD or WS_TABSTOP, rect.left, rect.top, rect.right, rect.bottom, hDlg, 0, hInst, nil); end; procedure TForm1.FormCreate(Sender: TObject); var w : HWND; begin w := CreateSysLink(Handle, HInstance, Rect(10, 50, 200, 40)); end;
사용법 #2]
unit SysLink; interface uses Windows, SysUtils, Classes, Controls, StdCtrls, CommCtrl, Messages; type TOnClickLink = procedure(Sender: TObject; AID, AURL: string) of object; TSysLink = class(TStaticText) private FOnClickLink: TOnClickLink; procedure SetOnClickLink(const Value: TOnClickLink); protected procedure CreateParams(var Params: TCreateParams); override; procedure WndProc(var Msg: TMessage); override; public published property OnClickLink: TOnClickLink read FOnClickLink write SetOnClickLink; end; procedure Register; implementation procedure Register; begin RegisterComponents('Win32', [TSysLink]); end; { TCustomSysLink } procedure TSysLink.CreateParams(var Params: TCreateParams); begin inherited; CreateSubClass(Params, WC_LINK); end; procedure TSysLink.SetOnClickLink(const Value: TOnClickLink); begin FOnClickLink := Value; end; procedure TSysLink.WndProc(var Msg: TMessage); var plink: PNMLink; begin case Msg.Msg of CN_NOTIFY: case TWMNotify(Msg).NMHdr.code of NM_CLICK, NM_RETURN: begin plink := PNMLINK(TMessage(Msg).LParam); if Assigned(FOnClickLink) then begin FOnClickLink(Self, WideCharToString(plink.item.szID), WideCharToString(plink.item.szUrl)); end; end; end; else inherited; end; end; end. // 사용 Demo:<a id="test" href="http://kingron.com" color="red">Test</a> Help Test procedure TForm1.syslnk1ClickLink(Sender: TObject; AID, AURL: string); begin ShowMessage(AID); ShowMessage(AURL); end;