Forum Discussion

doublewood's avatar
doublewood
Occasional Contributor
15 years ago

Keep Modeless Userforms dialog always on top

I have a script routine that shows a mode less status dialog which shows extracted info from a page(in testedapp) and update the caption on the userforms dialog the script than perform a ClickButton on the testedApp. the script than loop back and update the caption and so forth in a do while loop. Loop exit by user action or by timeout. This all work just fine in TestComplete but when I run it under TestExecute the userform dialog is cover by the testedapp when the clickbutton is executed. The only  work around I found so far is to hide the dialog and show it after the clickbutton event. But this produce flickering. Is there a way to keep the modeless dialog always on top? I was not able to find any property setting regarding the position of the dialog (z order) anywhere.







Regards

Mark Lin

3 Replies

  • Hi,



    You need to use the SetWindowPos API function to make your form the topmost window. There's an example here.
  • doublewood's avatar
    doublewood
    Occasional Contributor
    Jared,



    Thanks for the reply. I am using VBscript(newbie at that) and everything seems to be just fine. except the last line give me a error by the interpreter. Code completion knows about Win32API and SetWindowPos so it look like the parameter is not correct.



    Win32API.SetWindowPos( w1.Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE) 



    When I right click on the "Go to error" context menu the cursor show up between w1.Handle and HWND_TOPMOST



    also the line just above it

    w1 = p.Window("TUserForm","UserFormTemp")

    is TUserForm a constant that I should use while the second is the specific name for my userforms





    Regards

    Mark Lin
  • Hi Mark,



    In VBScript, you need to use the Call keyword since SetWindowPos has several parameters:

    Call Win32API.SetWindowPos( w1.Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE OR SWP_NOSIZE)




    is TUserForm a constant that I should use while the second is the specific name for my userforms


    TUserForm is a window class of the user form. It will be the same for all user forms. The second parameter is its caption. This is what you can see in your form's header.