Forum Discussion

blearyeye's avatar
blearyeye
Contributor
15 years ago

z-order of forms

I have a winform app (c# 4.0) that includes two forms, each of the same size and position. Both have the attribute visible and both are status normal. The user can select which should be on top; the program sets the topmost property of the form and then sets topmost back off. This results in the form being on top.



In TC, I want to confirm this operation. So I need to know the relative z-order of the two forms. Is there a way to tell?

1 Reply


  • Hi Bill,





    TestComplete assigns indexes to controls with the same name according to their z-order. So, the topmost form will have index 1. Here is the example of identifying forms according to their z-order:







    var className = "Form";

    var caption = "";

    var i = 1;

    var frm = parentObj.WaitWinFormsObject(className, caption, 1, 1000); //replace parentObj with the actual object

    while (true == frm.Exists) {

      Log.Message("Form #" + i + ": " + frm.Name);

      i++;

      frm = parentObj.WaitWinFormsObject(className, caption, i, 1000); //replace parentObj with the actual object

    }