-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.ts
More file actions
65 lines (53 loc) · 1.6 KB
/
example.ts
File metadata and controls
65 lines (53 loc) · 1.6 KB
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
import * as ffi from "ffi-napi";
import * as ref from "ref-napi";
import * as struct from "ref-struct-napi";
import * as reflection from "reflection_ui";
function start_message_loop() {
const MSG = struct({
hwnd: "pointer",
message: "int",
wParam: "pointer",
lParam: "pointer",
time: "int",
pt: struct({
x: "int",
y: "int"
})
});
const user32 = ffi.Library("user32.dll", {
"GetMessageA": [ "int", [ "pointer", "pointer", "uint", "uint" ] ],
"TranslateMessage": [ "int", [ "pointer" ] ],
"DispatchMessageA": [ "pointer", [ "pointer " ]]
});
const msg = ref.alloc(MSG);
while (user32.GetMessageA(msg, null, 0, 0) != 0) {
user32.TranslateMessage(msg);
user32.DispatchMessageA(msg);
}
}
function main(argv: string[], argc: number): number {
reflection.init_reflection();
const window = new reflection.browser_window({
width: 600,
height: 700,
name: "example window"
}, {
is_tab_list: false,
outline: true,
layout: 1,
max_size: false,
align: 0,
overflow: false,
border: true
});
window.register_event_handler(reflection.event_t.E_ON_RENDER_FINISHED, (ptr) => {
console.log("render finished");
});
const list = window.get_frame().add_button("button", (handle) => {
console.log("clicked\n");
}, { disabled: false, full_width: false });
window.start();
start_message_loop();
return 0;
}
process.exit(main(process.argv, process.argv.length));