开发者

Delphi: How can i get Handle for TComboBox component?

As far as I know, Combobox consists of two components: Edit and ListBox. How can I get Handle of Combob开发者_开发技巧ox, 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.


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


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;


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜