Author: Tomas Rutkauskas
DDE link to Netscape
Answer:
Create a new application with a form Form1, put the components on it as in the
following class defined (buttons, edit controls, labels and one TDDEClientConv) and
link the events to the given procedures.
Button3 will have Netscape open the entered url.
1 unit Netscp1;
2
3 interface
4
5 uses
6 SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls, Forms,
7 Dialogs, StdCtrls, DdeMan;
8
9 type
10 TForm1 = class(TForm)
11 DdeClientConv1: TDdeClientConv;
12 Button1: TButton;
13 Button2: TButton;
14 Button3: TButton;
15 LinkStatus: TEdit;
16 Label1: TLabel;
17 Label2: TLabel;
18 URLName: TEdit;
19 procedure Button1Click(Sender: TObject);
20 procedure FormCreate(Sender: TObject);
21 procedure Button2Click(Sender: TObject);
22 procedure Button3Click(Sender: TObject);
23 private
24 { private declarations }
25 public
26 { public declarations }
27
28 end;
29
30 var
31 Form1: TForm1;
32 LinkOpened: integer;
33
34 implementation
35
36 {$R *.DFM}
37
38 procedure TForm1.Button1Click(Sender: TObject);
39 begin
40 if LinkOpened = 0 then
41 begin
42 DdeClientConv1.SetLink('Netscape', 'WWW_OpenURL');
43 if DdeClientConv1.OpenLink then
44 begin
45 LinkStatus.Text := 'Netscape Link has been opened';
46 LinkOpened := 1
47 end
48 else
49 LinkStatus.Text := 'Unable to make Netscape Link'
50 end
51 end;
52
53 procedure TForm1.FormCreate(Sender: TObject);
54 begin
55 LinkOpened := 0
56 end;
57
58 procedure TForm1.Button2Click(Sender: TObject);
59 begin
60 DdeClientConv1.CloseLink;
61 LinkOpened := 0;
62 LinkStatus.Text := 'Netscape Link has been closed'
63 end;
64
65 procedure TForm1.Button3Click(Sender: TObject);
66 var
67 ItemList: string;
68 begin
69 if LinkOpened <> 0 then
70 begin
71 ItemList := URLName.Text + ',,0xFFFFFFFF,0x3,,,';
72 DdeClientConv1.RequestData(ItemList)
73 end
74 end;
75
76 end.
|