generated from finos/software-project-blueprint
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSymphonyNativeWindowHandleHelper.c
More file actions
58 lines (54 loc) · 1.75 KB
/
SymphonyNativeWindowHandleHelper.c
File metadata and controls
58 lines (54 loc) · 1.75 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
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#pragma comment( lib, "user32.lib" )
static HWND getMainContentNativeWindowHandle(HWND parentWindowHwnd) {
if( parentWindowHwnd == NULL ) {
return NULL;
}
HWND childWindowHwnd = FindWindowExA(parentWindowHwnd, 0, "Chrome_RenderWidgetHostHWND", NULL);
HWND titlebarWindowHwnd = NULL;
HWND contentWindowHwnd = NULL;
RECT titlebarRect;
RECT rect;
do {
if(GetWindowRect(childWindowHwnd, &rect)) {
int width = rect.right - rect.left;
int height = rect.bottom - rect.top;
}
if(titlebarWindowHwnd == NULL) {
titlebarWindowHwnd = childWindowHwnd;
contentWindowHwnd = childWindowHwnd;
GetWindowRect(childWindowHwnd, &titlebarRect);
} else {
if(childWindowHwnd && (rect.bottom - rect.top < titlebarRect.bottom - titlebarRect.top)) {
GetWindowRect(childWindowHwnd, &titlebarRect);
contentWindowHwnd = titlebarWindowHwnd;
titlebarWindowHwnd = childWindowHwnd;
} else {
contentWindowHwnd = childWindowHwnd;
}
}
childWindowHwnd = FindWindowExA(parentWindowHwnd, childWindowHwnd, "Chrome_RenderWidgetHostHWND", NULL);
}
while(childWindowHwnd != NULL);
if( contentWindowHwnd == NULL ) {
return NULL;
} else {
return contentWindowHwnd;
}
}
int main( int argc, char* argv[] ) {
if( argc == 2 ) {
HWND parentWindowHwnd = (HWND)( (uintptr_t) atoll( argv[ 1 ] ) );
HWND mainWindowContentHwnd = getMainContentNativeWindowHandle(parentWindowHwnd);
if(mainWindowContentHwnd != NULL) {
int a = (int)mainWindowContentHwnd;
printf("%i", a);
return EXIT_SUCCESS;
}
} else {
return EXIT_FAILURE;
}
}