/
function.go
590 lines (537 loc) · 20 KB
/
function.go
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
package win32
import (
"fmt"
"github.com/Mengdch/goUtil/FileTools"
"github.com/Mengdch/win"
"golang.org/x/sys/windows"
"path/filepath"
"syscall"
"unsafe"
)
type Thublink struct {
_dll *windows.LazyDLL
_wkeInitialize *windows.LazyProc
_wkeUnInitialize *windows.LazyProc
_wkeCreateWebView *windows.LazyProc
_wkeSetHandle *windows.LazyProc
_wkeOnPaintBitUpdated *windows.LazyProc
_wkeOnPaintUpdated *windows.LazyProc
_wkeLoadURL *windows.LazyProc
_wkeGetHostHWND *windows.LazyProc
_wkeResize *windows.LazyProc
_wkeNetOnResponse *windows.LazyProc
_wkeOnLoadUrlBegin *windows.LazyProc
_wkeFireMouseEvent *windows.LazyProc
_wkeFireContextMenuEvent *windows.LazyProc
_wkeFireWindowsMessage *windows.LazyProc
_wkeCreateWebWindow *windows.LazyProc
_wkeShowWindow *windows.LazyProc
_wkeFireMouseWheelEvent *windows.LazyProc
_wkeFireKeyUpEvent *windows.LazyProc
_wkeFireKeyDownEvent *windows.LazyProc
_wkeFireKeyPressEvent *windows.LazyProc
_wkeSetFocus *windows.LazyProc
_wkeNetGetRequestMethod *windows.LazyProc
_wkeNetSetData *windows.LazyProc
_wkeNetCancelRequest *windows.LazyProc
_wkeDestroyWebView *windows.LazyProc
_jsGetWebView *windows.LazyProc
_wkeKillFocus *windows.LazyProc
_wkeOnDidCreateScriptContext *windows.LazyProc
_wkeIsMainFrame *windows.LazyProc
_wkeGetString *windows.LazyProc
_wkeNetSetHTTPHeaderField *windows.LazyProc
_wkeNetChangeRequestUrl *windows.LazyProc
_wkeNetHookRequest *windows.LazyProc
_wkeNetHoldJobToAsynCommit *windows.LazyProc
_wkeNetContinueJob *windows.LazyProc
_wkeOnLoadUrlEnd *windows.LazyProc
_wkeOnConsole *windows.LazyProc
_wkeOnLoadUrlFail *windows.LazyProc
_wkeOnJsQuery *windows.LazyProc
_wkeOnDocumentReady2 *windows.LazyProc
_wkeOnDownload *windows.LazyProc
_wkeOnAlertBox *windows.LazyProc
_wkeOnCreateView *windows.LazyProc
_wkeSetContextMenuEnabled *windows.LazyProc
_wkeResponseQuery *windows.LazyProc
_wkeNetGetMIMEType *windows.LazyProc
_wkeNetSetMIMEType *windows.LazyProc
_wkeNetGetRawResponseHead *windows.LazyProc
_wkeSetTransparent *windows.LazyProc
_wkeSetViewProxy *windows.LazyProc
_wkeSetNavigationToNewWindowEnable *windows.LazyProc
_wkeSetUserAgent *windows.LazyProc
_wkeSetDebugConfig *windows.LazyProc
_wkePopupDialogAndDownload *windows.LazyProc
_wkeDownloadByPath *windows.LazyProc
_wkeGetLockedViewDC *windows.LazyProc
_wkeRunMessageLoop *windows.LazyProc
_wkeWebFrameGetMainFrame *windows.LazyProc
_wkeRunJs *windows.LazyProc
_wkeOnLoadingFinish *windows.LazyProc
_wkeEnableHighDPISupport *windows.LazyProc
_wkeOnTitleChanged *windows.LazyProc
_wkeNetGetFavicon *windows.LazyProc
_wkeReload *windows.LazyProc
_wkeGetUrl *windows.LazyProc
_wkeStopLoading *windows.LazyProc
_wkeGoBack *windows.LazyProc
_wkeGoForward *windows.LazyProc
_wkeCanGoForward *windows.LazyProc
_wkeGetTitle *windows.LazyProc
}
const (
dll_name = "node"
)
func (t *Thublink) Init() *Thublink {
lib := windows.NewLazyDLL(filepath.Join(fileFunc.NowPath(), getName()))
if !fileFunc.CheckFileExist(lib.Name) {
fmt.Println(lib.Name)
return nil
}
t._wkeSetViewProxy = lib.NewProc("mbSetViewProxy")
t._wkeSetTransparent = lib.NewProc("mbSetTransparent")
t._wkeOnDocumentReady2 = lib.NewProc("mbOnDocumentReady")
t._wkeNetGetRawResponseHead = lib.NewProc("mbNetGetRawResponseHeadInBlinkThread")
t._wkeNetSetMIMEType = lib.NewProc("mbNetSetMIMEType")
t._wkeNetGetMIMEType = lib.NewProc("mbNetGetMIMEType")
t._wkeOnLoadUrlFail = lib.NewProc("mbOnLoadUrlFail")
t._wkeOnLoadUrlEnd = lib.NewProc("mbOnLoadUrlEnd")
t._wkeNetContinueJob = lib.NewProc("mbNetContinueJob")
t._wkeNetHoldJobToAsynCommit = lib.NewProc("mbNetHoldJobToAsynCommit")
t._wkeNetHookRequest = lib.NewProc("mbNetHookRequest")
t._wkeNetChangeRequestUrl = lib.NewProc("mbNetChangeRequestUrl")
t._wkeNetSetHTTPHeaderField = lib.NewProc("mbNetSetHTTPHeaderField")
t._wkeGetString = lib.NewProc("mbGetString")
t._wkeOnConsole = lib.NewProc("mbOnConsole")
t._wkeIsMainFrame = lib.NewProc("mbIsMainFrame")
t._wkeOnDidCreateScriptContext = lib.NewProc("mbOnDidCreateScriptContext")
t._wkeKillFocus = lib.NewProc("mbKillFocus")
t._wkeNetCancelRequest = lib.NewProc("mbNetCancelRequest")
t._wkeNetSetData = lib.NewProc("mbNetSetData")
t._wkeNetGetRequestMethod = lib.NewProc("mbNetGetRequestMethod")
t._wkeFireKeyPressEvent = lib.NewProc("mbFireKeyPressEvent")
t._wkeFireKeyUpEvent = lib.NewProc("mbFireKeyUpEvent")
t._wkeFireKeyDownEvent = lib.NewProc("mbFireKeyDownEvent")
t._wkeFireMouseWheelEvent = lib.NewProc("mbFireMouseWheelEvent")
t._wkeFireContextMenuEvent = lib.NewProc("mbFireContextMenuEvent")
t._wkeFireWindowsMessage = lib.NewProc("mbFireWindowsMessage")
t._wkeCreateWebWindow = lib.NewProc("mbCreateWebWindow")
t._wkeShowWindow = lib.NewProc("mbShowWindow")
t._wkeFireMouseEvent = lib.NewProc("mbFireMouseEvent")
t._wkeOnLoadUrlBegin = lib.NewProc("mbOnLoadUrlBegin")
t._wkeNetOnResponse = lib.NewProc("mbNetOnResponse")
t._wkeLoadURL = lib.NewProc("mbLoadURL")
t._wkeGetHostHWND = lib.NewProc("mbGetHostHWND")
t._wkeResize = lib.NewProc("mbResize")
t._wkeOnPaintBitUpdated = lib.NewProc("mbOnPaintBitUpdated")
t._wkeOnPaintUpdated = lib.NewProc("mbOnPaintUpdated")
t._wkeSetHandle = lib.NewProc("mbSetHandle")
t._wkeCreateWebView = lib.NewProc("mbCreateWebView")
t._wkeInitialize = lib.NewProc("mbInit")
t._wkeUnInitialize = lib.NewProc("mbUninit")
t._wkeSetFocus = lib.NewProc("mbSetFocus")
t._wkeDestroyWebView = lib.NewProc("mbDestroyWebView")
t._jsGetWebView = lib.NewProc("jsGetWebView")
t._wkeOnDownload = lib.NewProc("mbOnDownloadInBlinkThread")
t._wkeOnAlertBox = lib.NewProc("mbOnAlertBox")
t._wkeOnCreateView = lib.NewProc("mbOnCreateView")
t._wkeSetContextMenuEnabled = lib.NewProc("mbSetContextMenuEnabled")
t._wkeSetNavigationToNewWindowEnable = lib.NewProc("mbSetNavigationToNewWindowEnable")
t._wkeSetUserAgent = lib.NewProc("mbSetUserAgent")
t._wkePopupDialogAndDownload = lib.NewProc("mbPopupDialogAndDownload")
t._wkeDownloadByPath = lib.NewProc("mbDownloadByPath")
t._wkeSetDebugConfig = lib.NewProc("mbSetDebugConfig")
t._wkeOnJsQuery = lib.NewProc("mbOnJsQuery")
t._wkeResponseQuery = lib.NewProc("mbResponseQuery")
t._wkeGetLockedViewDC = lib.NewProc("mbGetLockedViewDC")
t._wkeRunMessageLoop = lib.NewProc("mbRunMessageLoop")
t._wkeWebFrameGetMainFrame = lib.NewProc("mbWebFrameGetMainFrame")
t._wkeRunJs = lib.NewProc("mbRunJs")
t._wkeOnLoadingFinish = lib.NewProc("mbOnLoadingFinish")
t._wkeEnableHighDPISupport = lib.NewProc("mbEnableHighDPISupport")
t._wkeOnTitleChanged = lib.NewProc("mbOnTitleChanged")
t._wkeNetGetFavicon = lib.NewProc("mbOnNetGetFavicon")
t._wkeReload = lib.NewProc("mbReload")
t._wkeGetUrl = lib.NewProc("mbGetUrl")
t._wkeStopLoading = lib.NewProc("mbStopLoading")
t._wkeGoBack = lib.NewProc("mbGoBack")
t._wkeGoForward = lib.NewProc("mbGoForward")
t._wkeCanGoForward = lib.NewProc("mbCanGoForward")
t._wkeGetTitle = lib.NewProc("mbGetTitle")
var set mbSettings
set.mask = MB_ENABLE_NODEJS
r, _, err := t._wkeInitialize.Call(uintptr(unsafe.Pointer(&set)))
if r != 0 {
fmt.Println(err.Error())
}
return t
}
func GetBound(h win.HWND) win.RECT {
rect, e := win.GetWindowRect(h)
if !e {
return win.RECT{}
}
bn := win.RECT{
Left: rect.Left,
Top: rect.Top,
}
win.GetClientRect(h, &rect)
bn.Right = rect.Width() + bn.Left
bn.Bottom = rect.Height() + bn.Top
return bn
}
func (t *Thublink) wkeUnInit() {
t._wkeUnInitialize.Call()
}
func (t *Thublink) wkeOnDownload(wke wkeHandle, callback wkeOnDownloadCallback, param uintptr) {
t._wkeOnDownload.Call(uintptr(wke), syscall.NewCallback(callback), param)
}
func (t *Thublink) wkeOnAlertBox(wke wkeHandle, callback wkeOnAlertBoxCallback, param uintptr) {
t._wkeOnAlertBox.Call(uintptr(wke), syscall.NewCallback(callback), param)
}
func (t *Thublink) wkeOnCreateView(wke wkeHandle, callback wkeOnCreateViewCallback, param uintptr) {
t._wkeOnCreateView.Call(uintptr(wke), syscall.NewCallback(callback), param)
}
func (t *Thublink) wkeSetContextMenuEnabled(wke wkeHandle, show bool) {
t._wkeSetContextMenuEnabled.Call(uintptr(wke), uintptr(toBool(show)))
}
func (t *Thublink) wkeSetNavigationToNewWindowEnable(wke wkeHandle, b bool) {
t._wkeSetNavigationToNewWindowEnable.Call(uintptr(wke), uintptr(toBool(b)))
}
func (t *Thublink) wkeSetUserAgent(wke wkeHandle, ua string) {
p := strToCharPtr(ua)
t._wkeSetUserAgent.Call(uintptr(wke), p)
}
func (t *Thublink) wkeSetViewProxy(wke wkeHandle, proxy ProxyInfo) {
px := wkeProxy{
Type: int32(proxy.Type),
Port: uint16(proxy.Port),
}
for i, c := range proxy.HostName {
px.HostName[i] = byte(c)
}
if proxy.UserName != "" {
for i, c := range proxy.UserName {
px.UserName[i] = byte(c)
}
}
if proxy.Password != "" {
for i, c := range proxy.Password {
px.Password[i] = byte(c)
}
}
t._wkeSetViewProxy.Call(uintptr(wke), uintptr(unsafe.Pointer(&px)))
}
func (t *Thublink) wkeSetTransparent(wke wkeHandle, enable bool) {
t._wkeSetTransparent.Call(uintptr(wke), uintptr(toBool(enable)))
}
func (t *Thublink) wkeOnDocumentReady(wke wkeHandle, callback wkeDocumentReady2Callback, param uintptr) {
t._wkeOnDocumentReady2.Call(uintptr(wke), syscall.NewCallback(callback), param)
}
func (t *Thublink) wkeNetGetRawResponseHead(job wkeNetJob) map[string]string {
r, _, _ := t._wkeNetGetRawResponseHead.Call(uintptr(job))
var list []string
slist := *((*wkeSlist)(unsafe.Pointer(r)))
for slist.str != 0 {
list = append(list, ptrToUtf8(slist.str))
if slist.next == 0 {
break
} else {
slist = *((*wkeSlist)(unsafe.Pointer(slist.next)))
}
}
hMap := make(map[string]string)
for i := 0; i < len(list); i += 2 {
hMap[list[i]] = list[i+1]
}
return hMap
}
func (t *Thublink) wkeNetSetMIMEType(job wkeNetJob, mime string) {
p := strToCharPtr(mime)
t._wkeNetSetMIMEType.Call(uintptr(job), p)
}
func (t *Thublink) wkeNetGetMIMEType(job wkeNetJob) string {
r, _, _ := t._wkeNetGetMIMEType.Call(uintptr(job))
return ptrToUtf8(r)
}
func (t *Thublink) wkeOnLoadUrlFail(wke wkeHandle, callback wkeLoadUrlFailCallback, param uintptr) {
t._wkeOnLoadUrlFail.Call(uintptr(wke), syscall.NewCallback(callback), param)
}
func (t *Thublink) wkeOnJsQuery(wke wkeHandle, callback wkeJsQueryCallback, param uintptr) {
t._wkeOnJsQuery.Call(uintptr(wke), syscall.NewCallback(callback), param)
}
func (t *Thublink) wkeOnLoadUrlEnd(wke wkeHandle, callback wkeLoadUrlEndCallback, param uintptr) {
t._wkeOnLoadUrlEnd.Call(uintptr(wke), syscall.NewCallback(callback), param)
}
func (t *Thublink) wkeNetContinueJob(job wkeNetJob) {
t._wkeNetContinueJob.Call(uintptr(job))
}
func (t *Thublink) wkeNetHoldJobToAsynCommit(job wkeNetJob) {
t._wkeNetHoldJobToAsynCommit.Call(uintptr(job))
}
func (t *Thublink) wkeNetHookRequest(job wkeNetJob) {
t._wkeNetHookRequest.Call(uintptr(job))
}
func (t *Thublink) wkeNetChangeRequestUrl(job wkeNetJob, url string) {
p := strToCharPtr(url)
t._wkeNetChangeRequestUrl.Call(uintptr(job), p)
}
func (t *Thublink) wkeNetSetHTTPHeaderField(job wkeNetJob, name, value string) {
np := strToCharPtr(name)
vp := strToCharPtr(value)
t._wkeNetSetHTTPHeaderField.Call(uintptr(job), np, vp)
}
func (t *Thublink) wkeGetString(str wkeString) string {
r, _, _ := t._wkeGetString.Call(uintptr(str))
return ptrToUtf8(r)
}
func (t *Thublink) wkeOnConsole(wke wkeHandle, callback wkeConsoleCallback, param uintptr) {
t._wkeOnConsole.Call(uintptr(wke), syscall.NewCallback(callback), param)
}
func (t *Thublink) wkeIsMainFrame(wke wkeHandle, frame wkeFrame) bool {
r, _, _ := t._wkeIsMainFrame.Call(uintptr(wke), uintptr(frame))
return r != 0
}
func (t *Thublink) wkeOnDidCreateScriptContext(wke wkeHandle, callback wkeDidCreateScriptContextCallback, param uintptr) {
t._wkeOnDidCreateScriptContext.Call(uintptr(wke), syscall.NewCallback(callback), param)
}
func (t *Thublink) wkeKillFocus(wke wkeHandle) {
t._wkeKillFocus.Call(uintptr(wke))
}
func (t *Thublink) jsGetWebView(es jsExecState) wkeHandle {
r, _, _ := t._jsGetWebView.Call(uintptr(es))
return wkeHandle(r)
}
func (t *Thublink) wkeDestroyWebView(wke wkeHandle) {
t._wkeDestroyWebView.Call(uintptr(wke))
}
func (t *Thublink) wkeNetCancelRequest(job wkeNetJob) {
t._wkeNetCancelRequest.Call(uintptr(job))
}
func (t *Thublink) wkeNetOnResponse(wke wkeHandle, callback wkeNetResponseCallback, param uintptr) {
t._wkeNetOnResponse.Call(uintptr(wke), syscall.NewCallback(callback), param)
}
func (t *Thublink) wkeOnLoadUrlBegin(wke wkeHandle, callback wkeLoadUrlBeginCallback, param uintptr) {
t._wkeOnLoadUrlBegin.Call(uintptr(wke), syscall.NewCallback(callback), param)
}
func (t *Thublink) wkeNetGetRequestMethod(job wkeNetJob) wkeRequestType {
r, _, _ := t._wkeNetGetRequestMethod.Call(uintptr(job))
return wkeRequestType(r)
}
func (t *Thublink) wkeNetSetData(job wkeNetJob, buf []byte) {
if len(buf) == 0 {
buf = []byte{0}
}
t._wkeNetSetData.Call(uintptr(job), uintptr(unsafe.Pointer(&buf[0])), uintptr(len(buf)))
}
func (t *Thublink) wkeSetFocus(wke wkeHandle) {
t._wkeSetFocus.Call(uintptr(wke))
}
func (t *Thublink) wkeFireKeyPressEvent(wke wkeHandle, code, flags uint32, isSysKey bool) bool {
ret, _, _ := t._wkeFireKeyPressEvent.Call(
uintptr(wke),
uintptr(code),
uintptr(flags),
uintptr(toBool(isSysKey)))
return byte(ret) != 0
}
func (t *Thublink) wkeFireKeyDownEvent(wke wkeHandle, code, flags uint32, isSysKey bool) bool {
ret, _, _ := t._wkeFireKeyDownEvent.Call(
uintptr(wke),
uintptr(code),
uintptr(flags),
uintptr(toBool(isSysKey)))
return byte(ret) != 0
}
func (t *Thublink) wkeFireKeyUpEvent(wke wkeHandle, code, flags uint32, isSysKey bool) bool {
ret, _, _ := t._wkeFireKeyUpEvent.Call(
uintptr(wke),
uintptr(code),
uintptr(flags),
uintptr(toBool(isSysKey)))
return byte(ret) != 0
}
func (t *Thublink) wkeFireMouseWheelEvent(wke wkeHandle, x, y, delta, flags int32) bool {
r, _, _ := t._wkeFireMouseWheelEvent.Call(
uintptr(wke),
uintptr(x),
uintptr(y),
uintptr(delta),
uintptr(flags))
return byte(r) != 0
}
func (t *Thublink) wkeFireContextMenuEvent(wke wkeHandle, x, y, flags int32) bool {
r, _, _ := t._wkeFireContextMenuEvent.Call(
uintptr(wke),
uintptr(x),
uintptr(y),
uintptr(flags))
return byte(r) != 0
}
func (t *Thublink) wkeFireWindowsMessage(wke wkeHandle, hWnd win.HWND, message, wParam, lParam int32) bool {
r, _, _ := t._wkeFireWindowsMessage.Call(
uintptr(wke),
uintptr(hWnd),
uintptr(message),
uintptr(wParam),
uintptr(lParam),
uintptr(0))
return byte(r) != 0
}
func (t *Thublink) wkeCreateWebWindow(wt WindowType, parent win.HWND, x, y, width, height int32) wkeHandle {
r, _, _ := t._wkeCreateWebWindow.Call(
uintptr(wt),
uintptr(parent),
uintptr(x),
uintptr(y),
uintptr(width),
uintptr(height))
return wkeHandle(r)
}
func (t *Thublink) wkeShowWindow(wke wkeHandle, show bool) {
t._wkeShowWindow.Call(uintptr(wke), uintptr(toBool(show)))
}
func (t *Thublink) wkeFireMouseEvent(wke wkeHandle, message, x, y, flags int32) bool {
r, _, _ := t._wkeFireMouseEvent.Call(
uintptr(wke),
uintptr(message),
uintptr(x),
uintptr(y),
uintptr(flags))
return byte(r) != 0
}
func (t *Thublink) wkeResize(wke wkeHandle, w, h uint32) {
t._wkeResize.Call(uintptr(wke), uintptr(w), uintptr(h))
}
func (t *Thublink) wkeLoadURL(wke wkeHandle, url string) {
ptr := strToCharPtr(url)
t._wkeLoadURL.Call(uintptr(wke), ptr)
}
/*
设置一些实验性选项。debugString可用参数有:
*/
func (t *Thublink) wkeSetDebugConfig(wke wkeHandle, debug debugType, param string) {
dp := strToCharPtr(string(debug))
pp := strToCharPtr(param)
t._wkeSetDebugConfig.Call(uintptr(wke), dp, pp)
}
func (t *Thublink) wkeOnPaintBitUpdated(wke wkeHandle, callback wkePaintBitUpdatedCallback, param uintptr) {
t._wkeOnPaintBitUpdated.Call(uintptr(wke), syscall.NewCallback(callback), param)
}
func (t *Thublink) wkeOnPaintUpdated(wke wkeHandle, callback wkePaintUpdatedCallback, param uintptr) {
t._wkeOnPaintUpdated.Call(uintptr(wke), syscall.NewCallback(callback), param)
}
func (t *Thublink) wkeOnLoadingFinish(wke wkeHandle, callback wkeLoadingFinishCallback, param uintptr) {
t._wkeOnLoadingFinish.Call(uintptr(wke), syscall.NewCallback(callback), param)
}
func (t *Thublink) wkeOnTitleChanged(wke wkeHandle, callback wkeTitleChangedCallback, param uintptr) {
t._wkeOnTitleChanged.Call(uintptr(wke), syscall.NewCallback(callback), param)
}
func (t *Thublink) wkeEnableHighDPISupport() {
t._wkeEnableHighDPISupport.Call()
}
func (t *Thublink) wkeNetGetFavicon(wke wkeHandle, callback wkeNetGetFaviconCallback, param uintptr) {
t._wkeNetGetFavicon.Call(uintptr(wke), syscall.NewCallback(callback), param)
}
func (t *Thublink) wkeRunJs(handle wkeHandle, frame wkeFrame, script uintptr, isInClosure bool, callback wkeRunJsCallback, param, unUse uintptr) {
t._wkeRunJs.Call(uintptr(handle), uintptr(frame), script, uintptr(toBool(isInClosure)), 0, param, unUse)
}
func (t *Thublink) wkeSetHandle(wke wkeHandle, handle uintptr) {
t._wkeSetHandle.Call(uintptr(wke), handle)
}
func (t *Thublink) wkeOnShowDevtoolsCallback(wke uintptr, param uintptr) uintptr {
return 0
}
func (t *Thublink) wkeCreateWebView() wkeHandle {
r, _, _ := t._wkeCreateWebView.Call()
return wkeHandle(r)
}
func (t *Thublink) wkeGetHostHWND() win.HWND {
r, _, _ := t._wkeGetHostHWND.Call()
return win.HWND(r)
}
func (t *Thublink) wkeGetLockedViewDC(wke wkeHandle) win.HDC {
r, _, _ := t._wkeGetLockedViewDC.Call(uintptr(wke))
return win.HDC(r)
}
func (t *Thublink) wkeRunMessageLoop() {
t._wkeRunMessageLoop.Call()
}
func (t *Thublink) wkeWebFrameGetMainFrame(wke wkeHandle) wkeFrame {
r, _, _ := t._wkeWebFrameGetMainFrame.Call(uintptr(wke))
return wkeFrame(r)
}
func (t *Thublink) wkeReload(wke wkeHandle) {
t._wkeReload.Call(uintptr(wke))
}
func (t *Thublink) wkeGetUrl(wke wkeHandle) uintptr {
r, _, _ := t._wkeGetUrl.Call(uintptr(wke))
return r
}
func (t *Thublink) wkeStopLoading(wke wkeHandle) {
t._wkeStopLoading.Call(uintptr(wke))
return
}
func (t *Thublink) wkeGoBack(wke wkeHandle) {
t._wkeGoBack.Call(uintptr(wke))
return
}
func (t *Thublink) wkeGoForward(wke wkeHandle) {
t._wkeGoForward.Call(uintptr(wke))
return
}
func (t *Thublink) wkeCanGoForward(wke wkeHandle, callback wkeCanGoBackForwardCallback, param uintptr) {
t._wkeCanGoForward.Call(uintptr(wke), syscall.NewCallback(callback), param)
return
}
func (t *Thublink) wkeGetTitle(wke wkeHandle) uintptr {
r, _, _ := t._wkeGetTitle.Call(uintptr(wke))
return r
}
func strToCharPtr(str string) uintptr {
buf := []byte(str)
rs := make([]byte, len(str)+1)
for i, v := range buf {
rs[i] = v
}
return uintptr(unsafe.Pointer(&rs[0]))
}
func StrPtr(s string) (uintptr, error) {
fromString, err := syscall.UTF16PtrFromString(s)
if err != nil {
return 0, err
}
return uintptr(unsafe.Pointer(fromString)), nil
}
func ptrToByte(ptr uintptr, len uint32) []byte {
seq := make([]byte, len)
if ptr > 0 {
for i := uint32(0); i < len; i++ {
seq[i] = *((*byte)(unsafe.Pointer(ptr)))
ptr++
}
}
return seq
}
func ptrToUtf8(ptr uintptr) string {
var seq []byte
for ptr > 0 {
b := *((*byte)(unsafe.Pointer(ptr)))
if b != 0 {
seq = append(seq, b)
ptr++
} else {
break
}
}
return string(seq)
}
func toBool(b bool) byte {
if b {
return 1
} else {
return 0
}
}