Bill Zhang (Microsoft) responds to this question in a posting on microsoft.public.dotnet.frameworks.windowsforms newsgroup.
The Frameworks classes use P/Invoke to call the GetWindow API to get the HWND internally - there is no exposed way to do this. If you wish to get the Win32 HWND, here’s the code to do it, but there is no way to get a
System.Windows.Forms.Edit control from this.
[DllImport('user32.dll', ExactSpelling=true, CharSet=CharSet.Auto)]
public static extern IntPtr GetWindow(IntPtr hWnd, int uCmd);
public const int GW_CHILD = 5;
if (combo.DropDownStyle != ComboBoxStyle.DropDownList) {
IntPtr hwnd = GetWindow(combo.Handle, NativeMethods.GW_CHILD);
if (hwnd != IntPtr.Zero) {
editHandle = hwnd;
}
}
Share with