-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathufrmMain.pas
93 lines (78 loc) · 1.98 KB
/
ufrmMain.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
unit ufrmMain;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Wke, ExtCtrls;
type
TfrmMain = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
Button3: TButton;
Button2: TButton;
Button1: TButton;
Button4: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
private
FWebView: TWkeWebView;
public
{ Public declarations }
end;
var
frmMain: TfrmMain;
implementation
{$R *.dfm}
function test: String;
var
AMsg: string;
begin
AMsg := '这是Delphi字符串!!!';
ShowMessage(AMsg);
Result := AMsg;
end;
function test1(msg: String): String;
var
AMsg: string;
begin
AMsg := msg + ', 这是Delphi字符串!!!';
Result := AMsg;
end;
function _Test(p1, p2, es_: wkeJSState): wkeJSValue;
begin
Result := es_.String_(test);
end;
function _Test1(p1, p2, es_: wkeJSState): wkeJSValue;
var
_msg: String;
begin
_msg := (es_.ArgToString(es_, 0)); // 获取从Html传入的参数
Result := es_.String_(test1(_msg));
end;
procedure TfrmMain.FormCreate(Sender: TObject);
begin
FWebView:= wkeCreateWebWindow(WKE_WINDOW_TYPE_CONTROL, Panel1.Handle, 0, 0, Panel1.Width, Panel1.Height);
FWebView.Initialize;
FWebView.ShowWindow(True);
JScript.BindFunction('delphi_Test', @_Test, 1);
JScript.BindFunction('delphi_Test1', @_Test1, 1);
end;
procedure TfrmMain.Button1Click(Sender: TObject);
begin
FWebView.LoadFile('html\BallPool.html');
end;
procedure TfrmMain.Button2Click(Sender: TObject);
begin
wkeRunJS(FWebView, 'appTitle.checkText = "hahaha"')
end;
procedure TfrmMain.Button3Click(Sender: TObject);
begin
FWebView.LoadFile('html\index.vue.html');
end;
procedure TfrmMain.Button4Click(Sender: TObject);
begin
FWebView.LoadFile('html\index.html');
end;
end.