Skip to content

Commit 8cbc140

Browse files
save file
1 parent 83c761c commit 8cbc140

1 file changed

Lines changed: 33 additions & 26 deletions

File tree

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,36 @@
1-
#include <napi.h>
2-
#include <windows.h>
3-
4-
Napi::Value SetAlwaysOnTop(const Napi::CallbackInfo& info) {
5-
Napi::Env env = info.Env();
6-
7-
HWND hwnd = GetForegroundWindow();
8-
if (!hwnd) return Napi::Boolean::New(env, false);
9-
10-
BOOL result = SetWindowPos(
11-
hwnd,
12-
HWND_TOPMOST,
13-
0, 0, 0, 0,
14-
SWP_NOMOVE | SWP_NOSIZE
15-
);
16-
17-
return Napi::Boolean::New(env, result);
18-
}
19-
20-
Napi::Object Init(Napi::Env env, Napi::Object exports) {
21-
exports.Set("setAlwaysOnTop", Napi::Function::New(env, SetAlwaysOnTop));
22-
return exports;
23-
}
24-
25-
NODE_API_MODULE(alwaysontop, Init)
26-
271

282

293

4+
#include <napi.h>
5+
#include <windows.h>
6+
7+
Napi::Value SetAlwaysOnTop(const Napi::CallbackInfo& info){
8+
9+
Napi::Env env = info.Env();
10+
11+
HWND hwnd = GetForegroundWindow();
12+
if(!hwnd){
13+
return Napi::Boolean::New(env,false);
14+
}
15+
16+
BOOL result = SetWindowPos(hwnd,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE);
17+
18+
return Napi::Boolean::New(env, result);
19+
20+
}//SetAlwaysOnTop
21+
22+
23+
Napi::Object Init(Napi::Env env,Napi::Object exports) {
24+
25+
exports.Set("setAlwaysOnTop",Napi::Function::New(env,SetAlwaysOnTop));
26+
return exports;
27+
28+
}//Init
29+
30+
31+
NODE_API_MODULE(alwaysontop, Init)
32+
33+
34+
35+
36+

0 commit comments

Comments
 (0)