Powerbuilder 12.5 Get Parent Window Variable

2.3k Views Asked by At

Trying to get a Variable from a parent window of response window (both windows are inherited - I do not have the source code). I'm able to loop trough all parent variables, objects, controls etc. but I can't seem to read any of the variables. This code is for "ok event". Appreciate any help.

window lw_active, w_parentwindow
string ls_winname, ls_libname, ls_wintitle
ClassDefinition cd_windef


w_parentwindow = this.ParentWindow()
lw_active = w_parentwindow.GetFirstSheet()

if isvalid(lw_active) = True then
        ls_winname = lw_active.classname()

        cd_windef = FindClassDefinition(ls_winname)
        ls_libname = cd_windef.LibraryName
        ls_wintitle = lw_active.title

        messagebox(ls_winname, ls_libname+'~r~n~r~n'+ls_wintitle, Information!)       

        string s, lineend
integer li
VariableDefinition vard
lineend = "~r~n"
FOR li = 1 to UpperBound(cd_windef.VariableList)
   vard = cd_windef.VariableList[li]
   s = s + vard.Name + lineend
NEXT
messagebox('s',s) 

end if
1

There are 1 best solutions below

2
On
  1. Inherit the window that you want to access. I'll call your descendant window w_mine and the ancestor w_theirs.
  2. Add accessor methods to w_mine. You'll be able to reference anything in w_theirs that's not Private.
  3. Declare a variable of type w_mine.
  4. Assign the window reference to w_mine. You can then call the methods you added to w_mine.
  5. Don't destroy w_mine. Simply let it go out of scope. In PB it's not necessary to set the variable null or do anything special. Note that if you close the window your reference will become invalid. I would avoid using an instance variable to hold the reference.