Automation NativeWindowHandle of DateTimerPicker differs from HWND of it
Hello,
I'm working on UI Automation test of Windows Forms application. It contains a DateTimePicker, and I want to set its value from test independently from current user language.
I thought that ValuePattern could be used for this purpose. Getting value from it provides date in string format, corresponding to the long date format of the current language. But after formatting the date to be set in the same format and sending it with ValuePattern.SetValue, the date didn't get set.
That's why I tried to set the date with sending window message (DTM_SETSYSTEMTIME = 0x1002). I wrote a simple WinForms application to do the same inside the application, and it worked well. Then in the test code I queried native window handle with getting AutomationElement.Current.NativeWindowHandle value, and I sent the message to this window handle. But it didn't work at all. It turned out that the value read with AutomationElement.Current.NativeWindowHandle is equal to the real window handle of the DateTimePicker + 0x10000. The real window handle was read in the application containing the DateTimePicker instance.
That is very weird, because I also have code to automate ComboBox with window messages without any issue, in that case the real window handle of the ComboBox is the same as it is read out with AutomationElement.Current.NativeWindowHandle.
Could you help me how can I handle this issue, please?
Thanks in advance,
Sandor Michaletzky