Problem accessing mainform window
Hi all!
Since we migrated our testing machines to Windows10, we sometimes encounter problems using TestExecute (v11.31).
After our application is started, the mainform does not seem to have the focus.
Calling the SetFocus() method on the mainform results in this error:
"The window cannot get focus."
Calling Sys.Desktop.ActiveWindow() results in an exception
"Cannot find the window with handle 1234."
Once this error occurs, it is a permanent error (when I try Sys.Desktop.ActiveWindow() again after a minute, it will result in the same error).
It is not always reproducable.
I do not see anything else on the Win desktop except for the main window of our application. I'm not sure if Win10 causes this problem or not, but I think we did not see this on Win8.1.
Does anyone have an idea what may cause this?
Best regards
Jens Schwarz
Hi Jens,
I hope that you with Support guys will solve this problem. Just a quick note though: Window objects (what forms are) cannot get focus indeed. It is controls on the form that usually can be focused. Windows/forms must be activated instead using the .Activate() method.
Far not sure that this might help, but anyway...
Hi Alex,
Thanks for your reply, it´s the same that we were advised by the support team. SetFocus() on a form works for us usually - but not in this case. It's no problem to use Activate() instead of SetFocus(), but it bothers me a bit that we have to use Activate() everytime when we start a tested app to prevent that occasional error.
Anyway, it is working now.
Thanks...
Best regards
Jens Schwarz