@@ -181,10 +181,13 @@ Napi::Value getWindowInformation(const HWND &hwnd, const Napi::CallbackInfo &inf
181
181
return env.Null ();
182
182
}
183
183
184
- RECT lpRect ;
185
- BOOL rectResult = GetWindowRect (hwnd, &lpRect );
184
+ RECT lpWinRect ;
185
+ BOOL rectWinResult = GetWindowRect (hwnd, &lpWinRect );
186
186
187
- if (rectResult == 0 ) {
187
+ RECT lpClientRect;
188
+ BOOL rectClientResult = GetClientRect (hwnd, &lpClientRect);
189
+
190
+ if (rectWinResult == 0 || rectClientResult == 0 ) {
188
191
return env.Null ();
189
192
}
190
193
@@ -194,12 +197,26 @@ Napi::Value getWindowInformation(const HWND &hwnd, const Napi::CallbackInfo &inf
194
197
owner.Set (Napi::String::New (env, " path" ), ownerInfo.path );
195
198
owner.Set (Napi::String::New (env, " name" ), ownerInfo.name );
196
199
200
+ // bounds window
197
201
Napi::Object bounds = Napi::Object::New (env);
198
202
199
- bounds.Set (Napi::String::New (env, " x" ), lpRect.left );
200
- bounds.Set (Napi::String::New (env, " y" ), lpRect.top );
201
- bounds.Set (Napi::String::New (env, " width" ), lpRect.right - lpRect.left );
202
- bounds.Set (Napi::String::New (env, " height" ), lpRect.bottom - lpRect.top );
203
+ bounds.Set (Napi::String::New (env, " x" ), lpWinRect.left );
204
+ bounds.Set (Napi::String::New (env, " y" ), lpWinRect.top );
205
+ bounds.Set (Napi::String::New (env, " width" ), lpWinRect.right - lpWinRect.left );
206
+ bounds.Set (Napi::String::New (env, " height" ), lpWinRect.bottom - lpWinRect.top );
207
+
208
+ // bounds content
209
+ POINT rectTopLeft = {lpClientRect.left , lpClientRect.top };
210
+ ClientToScreen (hwnd, &rectTopLeft);
211
+ POINT rectBottomRight = {lpClientRect.right , lpClientRect.bottom };
212
+ ClientToScreen (hwnd, &rectBottomRight);
213
+
214
+ Napi::Object contentBounds = Napi::Object::New (env);
215
+
216
+ contentBounds.Set (Napi::String::New (env, " x" ), rectTopLeft.x );
217
+ contentBounds.Set (Napi::String::New (env, " y" ), rectTopLeft.y );
218
+ contentBounds.Set (Napi::String::New (env, " width" ), rectBottomRight.x - rectTopLeft.x );
219
+ contentBounds.Set (Napi::String::New (env, " height" ), rectBottomRight.y - rectTopLeft.y );
203
220
204
221
Napi::Object activeWinObj = Napi::Object::New (env);
205
222
@@ -208,6 +225,7 @@ Napi::Value getWindowInformation(const HWND &hwnd, const Napi::CallbackInfo &inf
208
225
activeWinObj.Set (Napi::String::New (env, " title" ), getWindowTitle (hwnd));
209
226
activeWinObj.Set (Napi::String::New (env, " owner" ), owner);
210
227
activeWinObj.Set (Napi::String::New (env, " bounds" ), bounds);
228
+ activeWinObj.Set (Napi::String::New (env, " contentBounds" ), contentBounds);
211
229
activeWinObj.Set (Napi::String::New (env, " memoryUsage" ), memoryCounter.WorkingSetSize );
212
230
213
231
return activeWinObj;
0 commit comments