//---------------------------------------------------------------------------

#include <vcl.h>

#pragma hdrstop

#include "LinkLabel.h"
#pragma package(smart_init)
//---------------------------------------------------------------------------
// ValidCtrCheck is used to assure that the components created do not have
// any pure virtual functions.
//

static inline void ValidCtrCheck(TLinkLabel *)
{
	new TLinkLabel(NULL);
}
//---------------------------------------------------------------------------
__fastcall TLinkLabel::TLinkLabel(TComponent* Owner)
	: TCustomLabel(Owner)
{
	TFontStyles LinkStyle;
	LinkStyle << fsUnderline;
	Font->Color=clNavy;
	Font->Style=LinkStyle;
	Cursor=crHandPoint;
	Adres="http://helion.pl";
	OnClick=Polacz;
}
//---------------------------------------------------------------------------
namespace Linklabel
{
	void __fastcall PACKAGE Register()
	{
		TComponentClass classes[1] = {__classid(TLinkLabel)};
		RegisterComponents("Helion", classes, 0);
	}
}
//---------------------------------------------------------------------------
bool TLinkLabel::SprawdzAdres(AnsiString AAdres) const
{
	return AAdres.SubString(1,7)=="http://";
}

void __fastcall TLinkLabel::SetAdres(AnsiString AAdres)
{
	if (!SprawdzAdres(AAdres)) AAdres="http://"+AAdres;
	FAdres=AAdres;
}

void __fastcall TLinkLabel::Polacz(TObject* Sender)
{
	Font->Color=clBlack;
	ShellExecute(NULL,"open",Adres.c_str(),NULL,NULL,SW_NORMAL);
}
