HowTo Get Window Handle or Control object for Edit part of ComboBox

  • Thread starter Thread starter Grigol Avetikov
  • Start date Start date
G

Grigol Avetikov

Hi,
I'm trying to get Control object of Edit part of ComboBox.
WinSpy shows that edit window is a child of combo, but HasChildren property
of combo returns false and components collection is empty.
I also tried to get the Control object with FromHandle method(using window
handle got from Spy) but it returns null.
I found that Edit part of Combo is kind of "Edit" class and usual .NET edit
control is
kind of "WindowsForms10.EDIT.app8" class.
It means Combo uses native Win32 control for edit part.
The question is how to handle these native Win32 controls from C# ?
Thanks
Best Regards,
Grigol Avetikov.
 
* "Grigol Avetikov said:
I'm trying to get Control object of Edit part of ComboBox.
WinSpy shows that edit window is a child of combo, but HasChildren property
of combo returns false and components collection is empty.
I also tried to get the Control object with FromHandle method(using window
handle got from Spy) but it returns null.
I found that Edit part of Combo is kind of "Edit" class and usual .NET edit
control is
kind of "WindowsForms10.EDIT.app8" class.
It means Combo uses native Win32 control for edit part.
The question is how to handle these native Win32 controls from C# ?

\\\
Private Declare Function GetWindow Lib "user32.dll" ( _
ByVal hwnd As IntPtr, _
ByVal wCmd As Int32 _
) As IntPtr
Private Declare Function SendMessage Lib "user32.dll" Alias
"SendMessageA" ( _
ByVal hwnd As IntPtr, _
ByVal wMsg As Int32, _
ByVal wParam As Int32, _
ByVal lParam As Int32 _
) As Int32

Private Const EM_SETPASSWORDCHAR As Int32 = &HCC

Private Const GW_CHILD As Int32 = 5

Private Sub Form1_Load( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs _
) Handles MyBase.Load
SendMessage( _
GetWindow( _
Me.ComboBox1.Handle, _
GW_CHILD _
), _
EM_SETPASSWORDCHAR, _
Asc("*"c), _
0 _
)
Me.ComboBox1.Refresh()
End Sub
///

Notice that this won't work with all combobox styles.
 
Back
Top