获取窗口 - GetWindow
函数简介
获取给定窗口相关的窗口句柄,如父窗口、子窗口、相邻窗口等
接口名称
GetWindow
DLL调用
long GetWindow(long ola, long hwnd, int flag)
参数定义:
ola
(长整型数): OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。hwnd
(长整型数): 窗口句柄。flag
(整型数): 指定要获取的窗口类型:- 0: 获取父窗口
- 1: 获取第一个子窗口
- 2: 获取First窗口
- 3: 获取Last窗口
- 4: 获取下一个窗口
- 5: 获取上一个窗口
- 6: 获取拥有者窗口
- 7: 获取顶层窗口
示例:
// 获取父窗口
long parent_hwnd = GetWindow(ola, hwnd, 0);
if (parent_hwnd != 0) {
printf("Parent window handle: %ld\n", parent_hwnd);
}
// 获取第一个子窗口
long child_hwnd = GetWindow(ola, hwnd, 1);
if (child_hwnd != 0) {
printf("First child window handle: %ld\n", child_hwnd);
}
// 获取拥有者窗口
long owner_hwnd = GetWindow(ola, hwnd, 6);
if (owner_hwnd != 0) {
printf("Owner window handle: %ld\n", owner_hwnd);
}
COM调用
long GetWindow(long hwnd, int flag)
参数定义:
hwnd
(长整型数): 窗口句柄。flag
(整型数): 指定要获取的窗口类型:- 0: 获取父窗口
- 1: 获取第一个子窗口
- 2: 获取First窗口
- 3: 获取Last窗口
- 4: 获取下一个窗口
- 5: 获取上一个窗口
- 6: 获取拥有者窗口
- 7: 获取顶层窗口
示例:
# 获取父窗口
parent_hwnd = ola.GetWindow(hwnd, 0)
messagebox("Parent window handle: " + parent_hwnd)
# 获取第一个子窗口
child_hwnd = ola.GetWindow(hwnd, 1)
messagebox("First child window handle: " + child_hwnd)
# 获取拥有者窗口
owner_hwnd = ola.GetWindow(hwnd, 6)
messagebox("Owner window handle: " + owner_hwnd)
返回值
长整型数:
- 返回指定类型的窗口句柄