سؤال

I have an AutomationElement A (MS UI Automation), which represents a combo box. I want to select n-th item in that combo box using Windows API call

IntPtr ComboBox_SetCurSel(IntPtr hWnd, int index)

A.NativeWindowHandle contains the handle of the combo box, but in order to pass it to ComboBox_SetCurSel, I need to convert it from int to IntPtr.

How?

هل كانت مفيدة؟

المحلول

Use the IntPtr(int) constructor.

IntPtr WindowHandle = new IntPtr(A.Current.NativeWindowHandle);
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top