nishay_patel
11 years agoOccasional Contributor
Modal User Forms to be on top of other windows.
I am running a test that has a modal form in it that pops up halfway through the test. I am running it via TestExecute. The problem is that whenever the modal form does show, it is never on top, always behind the Internet Explorer window that the rest of the test is using.
Is there a way to make a modal form show up on top of all other windows?
I tried what was suggested here: http://www.sqaforums.com/showflat.php?Cat=0&Number=478447&an=0&page=0&gonew=1
but this only seems to work for non-modal forms.
Thanks
Nish
Is there a way to make a modal form show up on top of all other windows?
I tried what was suggested here: http://www.sqaforums.com/showflat.php?Cat=0&Number=478447&an=0&page=0&gonew=1
but this only seems to work for non-modal forms.
Thanks
Nish
- Hi Nish,
The approach works for modal forms as well. The only thing is that you need to get a reference to the form first, then change its properties and only after that show it as modal one.
E.g.:
...
' make the form to be opened on top of all other ones
Set wUserForm = Sys.Process("Test*te").Window("TUserForm", UserForms.UFIssueParams.Caption, 1)
Call MakeWindowAlwaysOnTop(wUserForm)
' Displays the form and processes dialog results
Select Case UserForms.UFIssueParams.ShowModal
Case mrOk: ' The OK button was pressed
...
' Set the "AlwaysOnTop" style for a user form
Function MakeWindowAlwaysOnTop(Window)
MakeWindowAlwaysOnTop = Win32API.SetWindowPos(Window.Handle, HWND_TOPMOST, _
0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE)
End Function