获取前台CHILD窗口
每当 Skype 处于默认视图时,TConversationWindow
就会成为 tSkMainForm
窗口的子窗口。
我在查找哪个 TConversationWindow
处于活动状态时遇到问题 - 但它不像 MDI 界面 - 只有 一个 TConversationWindow
可见,就像它是一样标签/页面。
当我执行 GetForegroundWindow
时,将返回 Skype 的 MainForm 句柄 (tSkMainForm
)。有什么方法可以在 Skype 中获取前台 TConversationWindow
吗?
我的这个问题有 Skype 的屏幕截图默认视图,如果您需要的话。 :)
编辑:这是 Winspector Hierachy 的屏幕截图:
编辑2 :我尝试像这样穿过窗口:
procedure TForm1.Button1Click(Sender: TObject);
function GetClassName(Handle: HWND): String;
var
Buffer: array[0..MAX_PATH] of Char;
begin
Windows.GetClassName(Handle, @Buffer, MAX_PATH);
Result := String(Buffer);
end;
Var
Wnd: HWND;
SkypeWnd: HWND;
begin
SkypeWnd := FindWindow('tSkMainForm',nil);
Wnd := GetTopWindow(SkypeWnd);
while (GetClassName(Wnd) <> 'TConversationForm') and (Wnd <> 0) and (not IsWindowVisible(Wnd)) do
begin
Wnd := GetNextWindow(Wnd,GW_HWNDNEXT);
end;
Label1.Caption := GetClassName(Wnd)+' - '+GetHandleText(wnd);
end;
上面应该找到可见窗口,但是当我调试它时,它永远不会进入While循环内的Begin End,并且Label1显示“TChromeMenu - Chrome 工具栏”。当我删除 IsWindowVisible 检查时,它至少找到一个 TConversationForm。我做错了什么?
EDIT3:通过将 IsWindowVisible 和 getClassName 检查放在循环内,并在 true 时中断,我设法做到了。 :)
Whenever Skype is in Default View, the TConversationWindow
's become children of the tSkMainForm
Window.
I am having problems finding out which TConversationWindow
is active - however it's not like an MDI interface - only one TConversationWindow
is visible, like if it was a Tab/Page.
When I do GetForegroundWindow
, Skype's MainForm handle is returned (tSkMainForm
). Is there any way that I can get the foreground TConversationWindow
within Skype?
This question of mine has screenshots of Skype's Default View, if you need it. :)
EDIT: Here is a screenshot of the Winspector Hierachy:
EDIT2: I tried going thru the windows like this:
procedure TForm1.Button1Click(Sender: TObject);
function GetClassName(Handle: HWND): String;
var
Buffer: array[0..MAX_PATH] of Char;
begin
Windows.GetClassName(Handle, @Buffer, MAX_PATH);
Result := String(Buffer);
end;
Var
Wnd: HWND;
SkypeWnd: HWND;
begin
SkypeWnd := FindWindow('tSkMainForm',nil);
Wnd := GetTopWindow(SkypeWnd);
while (GetClassName(Wnd) <> 'TConversationForm') and (Wnd <> 0) and (not IsWindowVisible(Wnd)) do
begin
Wnd := GetNextWindow(Wnd,GW_HWNDNEXT);
end;
Label1.Caption := GetClassName(Wnd)+' - '+GetHandleText(wnd);
end;
The above is supposed to find the visible window, however when I debug it, it never enters the Begin End within the While loop, and Label1 displays "TChromeMenu - ChromeToolbar". When I remove the IsWindowVisible check, it atleast finds a TConversationForm. What am I doing wrong?
EDIT3: By placing the IsWindowVisible and getClassName check inside the loop, and break when true, I managed to do it. :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通过将 IsWindowVisible 和 getClassName 检查放在循环内,并在 true 时中断,我成功地做到了这一点。 :)
By placing the IsWindowVisible and getClassName check inside the loop, and break when true, I managed to do it. :)