Delphi-PRAXiS
Seite 2 von 2     12   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi RichEdit-Fragen (https://www.delphipraxis.net/30269-richedit-fragen.html)

NicoDE 22. Sep 2004 20:20

Re: RichEdit-Fragen
 
Zu zweitens...

Delphi-Quellcode:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Controls, Forms, StdCtrls, ComCtrls;

type
  TForm1 = class(TForm)
    RichEdit1: TRichEdit;
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
    procedure WmNotify(var Message: TWMNotify); message WM_NOTIFY;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

uses
  RichEdit, ShellAPI;

procedure TForm1.WmNotify(var Message: TWMNotify);
type
  PENLink = ^TENLink;
  TTextRange = TTextRangeA;
var
  Link: string;
  Text: TTextRange;
begin
  inherited;
  with Message do
    if (Result = Ord(False)) and Assigned(NMHdr) and (NMHdr.code = EN_LINK) then
      with PENLink(NMHdr)^ do
        if msg = WM_LBUTTONDOWN then
        begin
          SetLength(Link, chrg.cpMax - chrg.cpMin + 1);
          Link[1] := #0;
          Text.chrg := chrg;
          Text.lpstrText := PChar(Link);
          SendMessage(NMHdr.hwndFrom, EM_GETTEXTRANGE, 0, Integer(Addr(Text)));
          if StrLen(PChar(Link)) > 0 then
          begin
            ShellExecute(Handle, 'open', PChar(Link), nil, nil, SW_SHOWDEFAULT);
            Result := Ord(True);
          end;
        end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  with RichEdit1 do
  begin
    Perform(EM_AUTOURLDETECT, Ord(True), 0);
    Perform(EM_SETEVENTMASK, 0, Perform(EM_GETEVENTMASK, 0, 0) or ENM_LINK);
  end;
end;

end.
[edit] das kommt davon, wann man vor dem Abschicken des Beitrags noch schnell was essen geht *g* [/edit]


Alle Zeitangaben in WEZ +1. Es ist jetzt 03:40 Uhr.
Seite 2 von 2     12   

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz