我正在尝试将鼠标事件挂接到组合框。示例代码为here。
但是如果保留项目属性[Prefer 32 bit TRUE]则可以正常工作,但是如果我保留Prefer 32 bit FALSE,则GetComboBoxInfo API将失败,并显示错误代码87。
这里是代码失败的地方:
public static IntPtr GetChildListWindowHandle(Control ctrl)
{
Win32.ComboBoxInfo comboBoxInfo = new Win32.ComboBoxInfo();
comboBoxInfo.cbSize = (uint)Marshal.SizeOf(comboBoxInfo);
Win32.GetComboBoxInfo(ctrl.Handle, ref comboBoxInfo);
uint error = GetLastError() ;
if (true == Win32.GetComboBoxInfo(ctrl.Handle, ref comboBoxInfo))
{
return comboBoxInfo.hwndList;
}
return IntPtr.Zero;
}
[StructLayout(LayoutKind.Sequential)]
public struct ComboBoxInfo
{
public uint cbSize;
public RECT rcItem;
public RECT rcButton;
public IntPtr stateButton;
public IntPtr hwndCombo;
public IntPtr hwndEdit;
public IntPtr hwndList;
}
[DllImport("user32.dll")]
public static extern bool GetComboBoxInfo(IntPtr hwndCombo, ref ComboBoxInfo info);