1. Jonas Hitzler
  2. PowerBuilder
  3. Thursday, 5 August 2021 09:27 AM UTC

Currently Im coding in a datawindow that is placed on a userobject. Im trying to get the name of my userobject using parent or getparent(). Since the userobject is used as a tabpage, "parent" returns the tabpage instead of the userobject.

Is there any way I can get the userobject?

Thanks in advance,

Jonas

Accepted Answer
Benjamin Gaesslein Accepted Answer Pending Moderation
  1. Thursday, 5 August 2021 12:00 PM UTC
  2. PowerBuilder
  3. # Permalink

Ah, I see. In this case classname() returns the label you chose on the tab control. To get to the actual classname, you'll have to make use of the ClassDefinition object of your userobject. Replacing the clicked event code in your test code with this will do what you want:

ClassDefinition def
def = parent.classdefinition
Messagebox('',def.Ancestor.Name)

 

 

Comment
  1. René Ullrich
  2. Thursday, 5 August 2021 12:06 PM UTC
;-)
  1. Helpful
  1. Jonas Hitzler
  2. Thursday, 5 August 2021 12:53 PM UTC
Thanks, but I dont really need the string. I want to pass it as a powerobject. Is this possible?
  1. Helpful
  1. René Ullrich
  2. Thursday, 5 August 2021 13:05 PM UTC
The instance is "parent". It is of type tapage_... that is iherited from your userobject. So there is no instance that is directly of type of your userobject in this case! You could do a type cast.

uo_userobjecttofind luo_myuo

luo_myuo = parent
  1. Helpful
There are no comments made yet.
Benjamin Gaesslein Accepted Answer Pending Moderation
  1. Thursday, 5 August 2021 10:49 AM UTC
  2. PowerBuilder
  3. # 1

Hi Jonas,

your question is not very clear to me. You say you're trying to get the name of the userobject, yet both parent and getparent() will get you a reference to the object, not the name. What do you actually need? The classname? You're also saying your userobject that contains your DW control is used as a tabpage and you're dissatisfied that "parent" returns the tabpage... but your userobject *is* the tabpage in this case.

Maybe give us some example code and describe what you want to achieve and what goes wrong.

Comment
There are no comments made yet.
Jonas Hitzler Accepted Answer Pending Moderation
  1. Thursday, 5 August 2021 11:21 AM UTC
  2. PowerBuilder
  3. # 2

Hi Benjamin,

 

I think you gave me the answer I was looking for by explaining that the userobject IS the tabpage.

Im still including some example code so you might be able to understand what I was trying to achieve.

 

Thanks for helping me out

Attachments (1)
Comment
There are no comments made yet.
René Ullrich Accepted Answer Pending Moderation
  1. Thursday, 5 August 2021 11:41 AM UTC
  2. PowerBuilder
  3. # 3

Hi Jonas,

Your tabpage is an descendent of your userobject. If you call classname function for the parent you will get the classname of the descendent.

To get the classname of you userobject you have to evaluate the metaclass information.

Here a short example (without any IsNUll or IsValid validations):

classdefinition lcd_parent
lcd_parent = parent.classdefinition
Messagebox('',lcd_parent.ancestor.name)

 

Comment
There are no comments made yet.
Olan Knight Accepted Answer Pending Moderation
  1. Thursday, 5 August 2021 15:19 PM UTC
  2. PowerBuilder
  3. # 4

This is simple.

Let's say your environment is:
   tabpage  <-- tab <--- window

You can code like this:


w_your_window_type   lw_window
classdefinition               lcd_class [3]

lcd_class [1] = tabpage.ClassDefinition
lcd_class [2] = parent.ClassDefinition

// window       tabpg      tab             window
lw_window  =  tabpage.GetParent().GetParent()

lcd_class [3] = lw_window.ClassDefinition


Later -

Olan

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.