Autor Beitrag
Saubäär
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 376



BeitragVerfasst: Fr 27.10.06 00:18 
Hallo Forum!

Aus Neugier an der Programmierung von eigenen Komponenten habe ich angefangen mir eine eigene Komponente (TLink) von TLabel abzuleiten d.h. dass das Label (TLink) wie ein Hyperlink aussieht - hat auch alles wunderbar geklappt.

Ich will, dass mit einem Klick auf TLink eine Adresse im Browser geöffnet wird. Bis jetzt muss ich im OnClick- Ereignis immmer einen ShellExecute- Befehl eingeben.
Nun die Frage:

Ist es möglich, das OnClick- Ereignis in der neuen Komponente so zu modifizieren, das man im onClick- Ereignis den Shellbefehl NICHT nochmal eingeben muss?

Freue mich auf Antworten

Gruß

Saubäär

//Edit: Oh hab wohl die falsche Sparte erwischt. Sorry :)
rizla
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 417
Erhaltene Danke: 2

XP
FPC mit Lazarus
BeitragVerfasst: So 29.10.06 20:34 
Was heißt denn, nicht nochmal eingeben müssen? Irgendwo musst du es doch eingeben :gruebel:

ich habs ganz einfach so gemacht:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
constructor TLink.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
Cursor := crHandPoint;
fLink := 'http://www.delphi-forum.de'; ;)
Caption := fLink;
Hint := 'click here to open this site';
ShowHint := true;
Self.Font.Style := [fsBold,fsUnderline];
end;

destructor TLink.Destroy;
begin
 inherited Destroy;
end;

procedure TLink.Click;
begin
 inherited Click;
 ShellExecute(HInstance, PChar('open'),PChar('http:\\'+flink),nil,nil,0);
end;


aber das wird dir wohl nix nützen..
:r!a:

_________________
if you have what they want - they'll find a way to take it (bruce sterling)
WOW - 10 JAHRE Mitglied beim Delphi-Forum. Wie die Zeit vergeht, Freunde.
Saubäär Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 376



BeitragVerfasst: So 29.10.06 21:13 
Hey rizla!

Vielen Dank !!:)

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TLink.Click;
begin
 inherited Click;
 ShellExecute(HInstance, PChar('open'),PChar('http:\\'+flink),nil,nil,0);
end;


diese Procedure hat mir gefehlt. Habs so auch schon probiert, hab aber das inherited vergessen. Danke nochmal!!:)

Gruß

Bäär