Skip to content

Commit 50dba63

Browse files
committed
Update setParent
1 parent 4b4e6e0 commit 50dba63

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "node-window-manager",
3-
"version": "0.3.0",
3+
"version": "0.3.1",
44
"description": "Manage windows in macOS, Windows and Linux",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

src/classes/window.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,16 @@ export class Window {
133133
this.redraw();
134134
}
135135

136-
setParent(window: Window) {
137-
user32.SetWindowLongPtrA(
138-
this.handle,
139-
windows.GWLP_HWNDPARENT,
140-
window.handle
141-
);
136+
setParent(window: Window | null | number) {
137+
let handle = window;
138+
139+
if (window instanceof Window) {
140+
handle = window.handle;
141+
} else if (!window) {
142+
handle = 0;
143+
}
144+
145+
user32.SetWindowLongPtrA(this.handle, windows.GWLP_HWNDPARENT, handle);
142146
}
143147

144148
redraw() {

0 commit comments

Comments
 (0)