forked from perevoznyk/php4delphi
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathphp4Delphi.MainForm.pas
142 lines (129 loc) · 3.79 KB
/
php4Delphi.MainForm.pas
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
unit php4Delphi.MainForm;
interface
uses
System.Drawing, System.Collections, System.ComponentModel,
System.Windows.Forms, System.Data, System.Text, System.Runtime.InteropServices;
type
TWinForm = class(System.Windows.Forms.Form)
{$REGION 'Designer Managed Code'}
strict private
/// <summary>
/// Required designer variable.
/// </summary>
Components: System.ComponentModel.Container;
TextBox1: System.Windows.Forms.TextBox;
Button1: System.Windows.Forms.Button;
OpenFileDialog1: System.Windows.Forms.OpenFileDialog;
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
procedure InitializeComponent;
procedure Button1_Click(sender: System.Object; e: System.EventArgs);
{$ENDREGION}
strict protected
/// <summary>
/// Clean up any resources being used.
/// </summary>
procedure Dispose(Disposing: Boolean); override;
private
{ Private Declarations }
public
constructor Create;
end;
[assembly: RuntimeRequiredAttribute(TypeOf(TWinForm))]
implementation
uses php4Delphi.Standard;
{$AUTOBOX ON}
{$REGION 'Windows Form Designer generated code'}
/// <summary>
/// Required method for Designer support -- do not modify
/// the contents of this method with the code editor.
/// </summary>
procedure TWinForm.InitializeComponent;
begin
Self.TextBox1 := System.Windows.Forms.TextBox.Create;
Self.Button1 := System.Windows.Forms.Button.Create;
Self.OpenFileDialog1 := System.Windows.Forms.OpenFileDialog.Create;
Self.SuspendLayout;
//
// TextBox1
//
Self.TextBox1.Location := System.Drawing.Point.Create(8, 16);
Self.TextBox1.Multiline := True;
Self.TextBox1.Name := 'TextBox1';
Self.TextBox1.ScrollBars := System.Windows.Forms.ScrollBars.Both;
Self.TextBox1.Size := System.Drawing.Size.Create(272, 180);
Self.TextBox1.TabIndex := 0;
Self.TextBox1.Text := '';
//
// Button1
//
Self.Button1.Location := System.Drawing.Point.Create(12, 224);
Self.Button1.Name := 'Button1';
Self.Button1.TabIndex := 1;
Self.Button1.Text := 'Execute';
Include(Self.Button1.Click, Self.Button1_Click);
//
// OpenFileDialog1
//
Self.OpenFileDialog1.Filter := 'PHP files|*.php';
//
// TWinForm
//
Self.AutoScaleBaseSize := System.Drawing.Size.Create(5, 13);
Self.ClientSize := System.Drawing.Size.Create(292, 266);
Self.Controls.Add(Self.Button1);
Self.Controls.Add(Self.TextBox1);
Self.FormBorderStyle := System.Windows.Forms.FormBorderStyle.FixedDialog;
Self.MaximizeBox := False;
Self.MinimizeBox := False;
Self.Name := 'TWinForm';
Self.StartPosition := System.Windows.Forms.FormStartPosition.CenterScreen;
Self.Text := 'php4delphi';
Self.ResumeLayout(False);
end;
{$ENDREGION}
procedure TWinForm.Dispose(Disposing: Boolean);
begin
if Disposing then
begin
if Components <> nil then
Components.Dispose();
end;
inherited Dispose(Disposing);
end;
constructor TWinForm.Create;
begin
inherited Create;
//
// Required for Windows Form Designer support
//
InitializeComponent;
//
// TODO: Add any constructor code after InitializeComponent call
//
end;
procedure TWinForm.Button1_Click(sender: System.Object; e: System.EventArgs);
var
RequestID : integer;
L : integer;
builder : StringBuilder;
begin
if OpenFileDialog1.ShowDialog = System.Windows.Forms.DialogResult.OK then
begin
RequestID := InitRequest;
ExecutePHP(RequestID, OpenFileDialog1.FileName);
L := GetResultBufferSize(RequestID);
if L > 0 then
begin
builder := StringBuilder.Create;
builder.Capacity := L;
GetResultText(RequestID, builder, L +1);
TextBox1.Text := builder.ToString;
DoneRequest(RequestID);
builder.Free;
end;
end;
end;
end.