Delphi:如何获取 TComboBox 组件的句柄?

发布于 2024-10-06 19:30:15 字数 162 浏览 1 评论 0原文

据我所知,Combobox由两个组件组成:Edit和ListBox。如果我有编辑字段的句柄,如何获取组合框的句柄? 我尝试使用 GetWindow(MyHandle, GW_HWNDNEXT),其中 MyHandle 是我知道的 Edit 句柄,但结果始终为 0。有人有什么想法吗?

非常感谢。

As far as I know, Combobox consists of two components: Edit and ListBox. How can I get Handle of Combobox, if I have handle of it's Edit field ?
I tried to use GetWindow(MyHandle, GW_HWNDNEXT), where MyHandle is that handle of Edit that I know, but the result is always 0. Someone have any ideas?

Thx a lot.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

年华零落成诗 2024-10-13 19:30:15

“编辑”窗口是“组合框”窗口的子窗口:使用 <代码>GetParent

The Edit window is a child of the ComboBox window: Use GetParent.

无法言说的痛 2024-10-13 19:30:15

TCustomCombo 定义 ListHandleEditHandle 属性。这些具有受保护的可见性,但您始终可以通过子类化或使用标准技巧来获取受保护的成员来获取它们:

type
  TCheatComboBox = class(TComboBox);

function GetListHandle(Combo: TComboBox): HWND;
begin
  Result := TCheatComboBox(Combo).ListHandle;
end;

TCustomCombo defines ListHandle and EditHandle properties. These have protected visibility but you can always get at them by either subclassing or using the standard trick to get at protected members:

type
  TCheatComboBox = class(TComboBox);

function GetListHandle(Combo: TComboBox): HWND;
begin
  Result := TCheatComboBox(Combo).ListHandle;
end;
撩人痒 2024-10-13 19:30:15

您是如何获得 Edit 的句柄的?如果执行Combobox1.Handle,您将获得COMBOBOX 类窗口的句柄。

阅读 http://msdn.microsoft.com/en-us /library/bb775792(VS.85).aspx

How did you get the handle of the Edit? If you do Combobox1.Handle you get a handle for a COMBOBOX class window.

Read http://msdn.microsoft.com/en-us/library/bb775792(VS.85).aspx

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文