Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

make a copy of a window object instance 1

Status
Not open for further replies.

Andyfives

Programmer
Feb 22, 2002
46
DK
Hello there

I have a window object that has the usual stuff on it, with a userobject.

This userobject itself has 5 other userobjects contained in it, which each have a datawindow on each among other things.

On a window event, I would like the user to be able to create a new window which would be a "clone"/"deep copy" of the existing window object and everything contained on it.

Is this possible? I have worked with this in c# with a very simple object example and it was there.

Maybe I am getting myself confused unnecessarily and there is a better means. Perhaps I could use GetFullState to copy the dw's? or even work at the first userobject level instead of at the window level?

If anyone has experience on this one please let me know.

Thank you in advance

Andy
 
never tried it but I'd say it will be "easy" doing things the next way:

there's a function "Create using <ls_string_variable>'
and there's OpenUserObject()/ OpenUserobjectwithparm() (for visual objects) (do a search in the help of pb)

I'd suggest the second one: openuserobject(). Since it only accepts userobjects, when (for example) you want to create a commandbutton, you need to create a userobject, standar class, choose type commandbutton and then save and use that object for openuserobject().
This of course demands that the window you want to copy from must only use this kind of controls/userobjects instead of "direct" command buttons, datawindows, etc.

Check out the ClassDefinition() function to find out about objects.



hope it helps and good luck, lots of work ...

regards,
Miguel L.
 
in addition:

every window and userobject has an array named 'control[]' that you can process in a loop. To find out the type of object use the 'typeof()' function, classname(), etc..

regards,
Miguel L.
 
Hi miguelleeuwe,

Thank you for your BIG help on this one. It has given me many ideas. I am looking at the ClassDefinition() function especially. I see it returns a great deal of properties.
If I can find a good way to walk through this structure.... :)

Along with some of the other points you mentioned I think I can see a way to get this to work.

I will be back with a report on my findings.

Andy
 
I'm happy to have been usefull.

I've been just using the classdefinition object for one simple reason:

If I want to know if an object has for example a text attribute, I'd normally check if it's a statict text, singlelineEdit, etc. The problem is that the TypeOf() function does not return a statictext! when I used a standard userobject of type statictext. It would return for example a u_st object (being my userobject of type statictext). For that reason I found somewhere the very usefull function "returnvalue boolean f_is_a( powerobject apo, string 'classname'):

boolean lb_ret = false
classdefinition lcd_class_def

if isnull(apo_to_check) then return false
if not isvalid(apo_to_check) then return false
if isnull(apo_to_check.classdefinition) then return false
if not isvalid(apo_to_check.classdefinition) then return false

lcd_class_def = apo_to_check.classdefinition
do while not isnull(lcd_class_def) and isvalid(lcd_class_def)
if upper(lcd_class_def.name) = upper(as_class_name) then
lb_ret = true
exit //the loop
end if
lcd_class_def = lcd_class_def.ancestor
loop

return lb_ret


if I'd pass my u_st as a powerobject, it'll drill down to find out if in the end it results to be inherited from a statictext.

I'm using it to get all labels, titles, text values from a table and according to lenguage assign a value to all text-able objects.
Check out the 'object browser' (first pb toolbar being 2 small cubes and glasses) and check the system tab. On the left, mark 'show hierarchy' with right mouse button. You'll see that a graphicobject has a tag attribute. Once f_is_a() returns true, inside that if I drill down to see if it's also a windowobject, .... also a dragobject, ... singlelineedit, etc. to assign the rest of the posible text-able attributes that might have one of my special marks, indicating they have to be obtained from the database and assigned. (don't know if the order of object is correct, but you'll understand the idea):
if for example I found my powerobject is a statictext, I assign the text value and after check if it is also a static
staticHyperlink to also check and assign for the url- property that might be diferent for diferent languages.

;) have fun, once you've got it working it's great.

regards,
Miguel L.
 
by the way I made a mistake in my first answer:

"This of course demands that the window you want to copy from must only use this kind of controls/userobjects instead of "direct" command buttons, datawindows, etc."

this is not true, you can also create for example a u_st (being a userobject of type statictext). The problem is that you'd have to stick to a fixed range of posible userobjects and check all of them.

regards,
Miguel L.
 
another suggestion:

"Create using <ls_string_variable>'

the "ls_string_variable" you could obtain it by using the classname() function.


regards,
Miguel L.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top