Autor Beitrag
garfi
Hält's aus hier
Beiträge: 10

XP SPII
Delphi 2005 Personal
BeitragVerfasst: Mo 07.11.05 00:03 
Ich würde gerne den Linklabel benutzen, um von meinem Programm direkt auf eine Website zu gelangen. Wenn ich aber darauf klicke, passiert einfach nichts...


ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
procedure TWinForm.TWinForm_Load(sender: System.Object; e: System.EventArgs);
const link1= 'http://www.mandarintools.com';
begin
  linklabel1.Text:= link1;
  linklabel1.Links.Add(0,link1.Length,link1);
  ...


Was habe ich da falsch gemacht?

Moderiert von user profile iconraziel: Delphi-Tags hinzugefügt.
Moderiert von user profile iconChristian S.: Topic aus .NET verschoben am So 06.11.2005 um 23:18
bjd
Hält's aus hier
Beiträge: 11

Win XP Professional
Delphi 4 Std., Delphi 7 Pers., Object Pascal
BeitragVerfasst: Mi 28.12.05 14:33 
Titel: Ganz einfach!
Hi garfi!

Ich hab da einen anderen Quelltext, der ganz gut funktioniert! 8)
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
uses ShellApi;

procedure TForm1.Button1Click(Sender: TObject);
begin
    if shellexecute handle,'open','http://www.delphi-forum.de',nil,nil,sw_show)<=32 then
        MessageDlg('Internetseite konnte nicht geöffnet werden!'+#13+
                   'Versuchen Sie es zu einem späteren Zeitpunkt noch einmal',
                    mtError, [mbOK], 0);
end;


Statt "http://www.delphi-forum.de" kann natürlich alles andere eingesetzt werden!

Moderiert von user profile iconChristian S.: Code- durch Delphi-Tags ersetzt
kiar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 51



BeitragVerfasst: Mi 28.12.05 14:43 
hallo Benjamin,

du siehst schon, das du das hier in einem c# forum gepostet hast?
da wird ungern gesehen, das man die API nimmt.

raik
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Mo 02.01.06 19:45 
Hallo!

Das Linklabel tut von sich aus gar nichts ;-) Du musst im OnClick-Event selber dafür sorgen, dass sich etwas tut. Hier mal das Beispiel, welches auch in der Dokumentation enthalten ist (ist das im SDK 2.0 hinzugekommen?):

ausblenden volle Höhe C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
// Create a new LinkLabel control.
  private LinkLabel linkLabel1 = new LinkLabel();
  
  public void InitializeMyLinkLabel()
  {
      
      // Set the control to autosize based on the text content.
      linkLabel1.AutoSize = true;
      // Position and size the control on the form.
      linkLabel1.Location = new System.Drawing.Point(8,16);
      linkLabel1.Size = new System.Drawing.Size(135,13);
      // Set the text to display in the label.
      linkLabel1.Text = "Click here to get more info.";

      // Create a new link using the Add method of the LinkCollection class.
      linkLabel1.Links.Add(6,4,"www.microsoft.com");

      // Create an event handler for the LinkClicked event.
      linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkClicked);

      // Add the control to the form.
      this.Controls.Add(linkLabel1);
  }

  private void linkLabel1_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
  {
      // Determine which link was clicked within the LinkLabel.
      linkLabel1.Links[linkLabel1.Links.IndexOf(e.Link)].Visited = true;
      // Display the appropriate link based on the value of the LinkData property of the Link object.
      System.Diagnostics.Process.Start(e.Link.LinkData.ToString());
  }


Ist zwar in C#, sollte Dir aber trotzdem helfen.

Grüße
Christian

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".