Why ComboBox hides cursor when DroppedDown is set?
I got this issue on a Delphi application. As suggested here I just added SendMessage(ComboBox1.Handle, WM_SETCURSOR, 0, 0)
after any DropDown event and it worked.
In fact I was able to resolve this issue in this way:
#region Dirty methods :)
#pragma warning disable 169
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
public static extern void mouse_event(long dwFlags, long dx, long dy, long cButtons, long dwExtraInfo);
private const int MOUSEEVENTF_ABSOLUTE = 0x8000;
private const int MOUSEEVENTF_MOVE = 0x1;
private const int MOUSEEVENTF_LEFTDOWN = 0x02;
private const int MOUSEEVENTF_LEFTUP = 0x04;
private const int MOUSEEVENTF_RIGHTDOWN = 0x08;
private const int MOUSEEVENTF_RIGHTUP = 0x10;
#pragma warning restore 169
#endregion
private void button1_Click(object sender, EventArgs e) {
Point oldCursorPos = Cursor.Position; // save pos
Point a = comboBox1.Parent.PointToScreen(comboBox1.Location);
a.X += comboBox1.Width - 3;
a.Y += comboBox1.Height - 3;
Cursor.Position = a;
// simuate click on drop down button
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
Cursor.Position = oldCursorPos; // restore pos
}
But it is not the solution I want :( It is rather a crutch but not a solution.
I was able to work around the problem like this:
comboBox1.DroppedDown = true;
Cursor.Current = Cursors.Default;