为什么有些控件没有一个窗口办理? [英] How come some controls don't have a windows handle?

查看:154
本文介绍了为什么有些控件没有一个窗口办理?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望得到一些控件的窗口句柄做一些东西,它(需要手柄)。这种控制的不同的应用程序。

I want to get the window handle of some controls to do some stuff with it (requiring a handle). The controls are in a different application.

奇怪的;我发现很多控件没有一个窗户把手,像工具栏(?)在Windows资源管理器的按钮。只要设法得到一个处理的文件夹/搜索/(等)的按钮。它只是给我0。

Strangely enough; I found out that many controls don't have a windows handle, like the buttons in the toolbar (?) in Windows Explorer. Just try to get a handle to the Folder/Search/(etc) buttons. It just gives me 0.

所以..第一个问题:怎么来的,有些控件没有窗口办理?是不是所有控件的窗口,在他们的心中? (刚才讲的标准控件,就像我希望他们在Windows资源管理器中,在一个窗格或像什么customdrawn。)

So.. first question: how come that some controls have no windows handle? Aren't all controls windows, in their hearts? (Just talking about standard controls, like I would expect them in Windows Explorer, nothing customdrawn on a pane or the like.)

这让我想起我的第二个问题:如何与他们合作(如使用EnableWindow),如果你不能得到他们的句柄

Which brings me to my second question: how to work with them (like using EnableWindow) if you cannot get their handle?

对于任何输入非常感谢!

Many thanks for any inputs!

编辑(附加信息):

Windows资源管理器只是一个例子。这个问题我已经频繁 - 在不同的应用程序(一个我在,专有一个人真正感兴趣)。我有物理控制(因为我可以得到这些控件的AutomationElement),但它们没有窗户处理。另外,我想发送消息(SendMessage函数)来获得按钮状态,试图找出是否是推还是不(它是一个标准的按键,似乎只有通过消息表现出这种行为 - 至少就我都看到了。而且,按下的状态可以在该按钮持续了很多时间比你所期待的标准按键,虽然Windows资源管理器按钮,显示出类似的行为,像个按钮式的复选框,虽然他们是(按)按钮)。 SendMessage函数需要一个窗口句柄。

Windows Explorer is just an example. I have the problem frequently - and in a different application (the one I am really interested in, a proprietary one). I have "physical" controls (since I can get an AutomationElement of those controls), but they have no windows handle. Also, I am trying to send a message (SendMessage) to get the button state, trying to find out whether it is pushed or not (it is a standard button that seems to exhibit that behaviour only through that message - at least as far as I have seen. Also, the pushed state can last a lot longer on that button than you would expect on a standard button, though the Windows Explorer buttons show a similar behaviour, acting like button-style checkboxes, though they are (push)buttons). SendMessage requires a window handle.

是否以某种方式改变工具栏及其子元素的行为?拿走他们的窗口句柄或类似的东西? (使用识别父手柄/控制ID?)但随后如何在那些需要处理窗口控件使用的功能呢?

Does a ToolBar in some way change the behaviour of its child elements? Taking away their window handle or something similar? (Using parent handle/control id for identification??) But then how to use functions on those controls that require a windows handle?

推荐答案

如果他们没有一个把手,他们是不是真正的控制,他们只是吸引到像控制。

If they don't have a handle, they're not real controls, they're just drawn to look like controls.

不过,当然,在Windows资源管理器的工具栏按钮的的有窗口句柄,他们是一个工具栏的一部分。使用工具栏操作功能的与他们进行互动,而不是 EnableWindow

But of course, the toolbar buttons in Windows Explorer do have window handles, they're part of a toolbar. Use the toolbar manipulation functions to interact with them, not EnableWindow.

或者,更好的是,使用记录的API对于像搜索。逆向工程Windows资源管理器的从不截至很好的人,至少所有穷人Windows Shell中的队伍,具有多年的某些开发商谁想到,API对于其他人向后兼容黑客背负。不管你做什么设法让工作很可能在Windows的下一版本打破。

Or, better yet, use the documented APIs for things like search. Reverse-engineering Windows Explorer has never ended well for anyone, least of all the poor Windows Shell team, saddled with years of backwards-compatibility hacks for certain developers who thought that APIs are for everyone else. Whatever you do manage to get to work is very likely to break on the next version of Windows.

这篇关于为什么有些控件没有一个窗口办理?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆