Forum Discussion

sastowe's avatar
sastowe
Super Contributor
13 years ago

vb6 app what is the default button

I have a test in whcih I want to check which button on a dialog is DEFAULT . The way a msgbox is rendered is by passing in parameters. The sum of the numners determine how the Msgbox is displayed.





Is there any way to determine, in Test Complete what the second argument contains? Or how the screen looks? Or really what I am trying to do, which button is the default button.



Thanks





http://www.vb6.us/tutorials/understanding-msgbox-command-visual-basic

4 Replies



  • Hi Stephanie



    Following function will return you the default button of Msgbox, I have only tested with

    vbYesNo, I hope It will work for other configuration as well.



    Note: use this funtion as you get a msgbox without Keying tab or transfer focus to other button.


     



    function test5()

    {



    var def_but = Get_Default_Button(Aliases.Orders.dlgConfirm);

    Log.Message(def_but.WndCaption);



    }



    function Get_Default_Button(dlg)

    {



    dlg.Activate();

    var dic = dlg.FindAllChildren("WndClass", "Button", 5);

    dic = (new VBArray(dic)).toArray();



    for( i=0; i < dic.length; i++)

    {



    if((dic.WndStyles & Win32API.WS_BORDER == Win32API.WS_BORDER) == 1)

    return dic;



    }

    }


  • sastowe's avatar
    sastowe
    Super Contributor
    Can you explain this condition



    if((dic.WndStyles & Win32API.WS_BORDER == Win32API.WS_BORDER) == 1)



    Please?