Hello all,
Does anyone know how programmatically get a list of all Windows/Webpages (active or not) at runtime? Alternatively, is there a way to do this at design time?
Thanks,
Tim
Hello all,
Does anyone know how programmatically get a list of all Windows/Webpages (active or not) at runtime? Alternatively, is there a way to do this at design time?
Thanks,
Tim
you can only get ones that have an instance
on desktop check out WindowCount and the Window() function
on web its s little harder as you have to ask each session for its pages
see Session.PageCount and Session.PageAtIndex
why would you need this at design time ?
Thanks Norman, thats not what I am after.
What I am trying to do is to programmatically create a list of all Windows/Web Pages to use as part of user access control - limited users ability to access certain parts of the application.
Tim
You could write an IDE script that iterates over every item in you project and gets its name and type
Thats as close as you’ll get in the IDE
At runtime unless they have instances you cannot tell what ones might ever exist
Here’s an IDE script that may help. It collects all Window names then adds code to an existing Window to show each from a PushButton. I included the whole script but the part before the ****** is all you’ll care about. The foundWindows array should contain all your Window names.
[code]//Requires: Window named “AllWindowOpener” with a Pushbutton named “OpenButton”,
//placed above the titlebar and made into a Control Set. Action the “Action” event
//to OpenButton and the “Open” event to the window itself. Then run this script
//and those events are filled in with code to clone the buttons in open and
//show each window in action
//collect all windows in project
dim curFullName, curPartName, curType, foundWindows() As String, i As integer
dim stack() As String = Sublocations("").Split(ChrB(9)) //get root
while stack.ubound >= 0
curFullName = stack(stack.ubound) //get last name in stack
curPartName = NthField(curFullName, “.”, CountFields(curFullName, “.”))
stack.remove(stack.ubound) //and remove from stack
//if curFullName = “App” or curFullName = “Build Automation” then continue while //skip these
if curPartName = “AllWindowOpener” then continue while //skip the building to window
curType = PropertyValue(curPartName + “.Super”)
if curType = “Window” then //store if a window
foundWindows.Append curPartName
elseif curType = “” then //recurse on folders, type = “”
dim sa() As String = Sublocations(curFullName).Split(ChrB(9))
for i = 0 to sa.ubound
stack.append curFullName + “.” + sa(i)
next
end
wend
foundWindows.Sort
//*******************************************************
//build source code for Open and Action events
dim openCode(), actionCode() As String
dim lastIdx As integer = foundWindows.Ubound
openCode.Append “dim p As PushButton”
openCode.Append “for i As integer = 0 to " + Str(lastIdx)
openCode.Append “p = new OpenButton”
openCode.Append “p.Top = 14 + i * 32”
openCode.Append “next”
for i = 0 to lastIdx
openCode.Append “OpenButton(” + Str(i+1) + “).Caption = “”” + foundWindows(i) + “””"
next
actionCode.Append “Select Case index”
for i = 0 to lastIdx
actionCode.Append "Case " + Str(i+1)
actionCode.Append foundWindows(i) + “.Show”
next
actionCode.Append “End”
//set new source code in destinations
dim destOpen, destAction, errs() As String
destOpen = “AllWindowOpener.Open”
destAction = “AllWindowOpener.Controls.OpenButton.Action”
Location = destOpen
if Location = destOpen then
Text = Join(openCode, EndOfLine)
else
errs.Append “No " + destOpen + " event”
end
Location = destAction
if Location = destAction then
Text = Join(actionCode, EndOfLine)
else
errs.Append “No " + destAction + " event”
end
//feedback
if errs.Ubound < 0 then
if showdialog(“success”, “”, “ok”) = “” then beep
else
if showdialog(“errors”, Join(errs, EndOfLine), “ok”) = “” then beep
end[/code]
Thanks Will!
An unexpected Christmas gift!
Thank you too Norman for your response and help!
Tim