Hyderabad Jobs Book Website FREE PowerBuilder Training I Love Hyderabad Hyderabad Colleges
Home Business Emails Hyderabad Classifieds Contact Us
7 Wonders of Hyderabad Web Hosting Yellow Pages Our Network

 
Webpowerbuilder.hyderabad-colleges.com

Advanced PowerBuilder

HomePrevious Lesson: Custom Class
Next Lesson: Summary

Notes on User Object Programming

This section contains useful hints and tips, for using the created user objects.

User Objects on Windows

You can use user objects in a window in two ways:
By placing the user object in a window.
By opening the user object dynamically from script.

When you place an user object in the window, you must give it a name just as you would for any other type of controls. You can then refer to the user object in your script by using this name.

Resizing user objects

When the user object is resized, the controls within don't resize accordingly. To allow the user to resize the user object at execution time, you need to write the code for doing it.

Time Related Existence

There may be situations where you only need the user object to exist in the window for a certain period of time. You can do this in one of two ways:
1 You can place the user object in the window and toggle its visible property, so that it gets displayed only when you need it. Here, the memory used is same in both the cases.
2 You can open the user object dynamically whenever required and close it down when it is no longer needed. The function to open the user object is OpenUserObject(). To send parameters to the user object, you can use OpenUserObjectWithParm(). In both the functions, you can specify the x and y co-ordinates of the user object in the window.

Placing Non-Visual User Objects

You can't place a class user object ( Non-Visual user object ) on the surface of a window. What you can do is, declare a variable and create an instance of the class and access that instance. For example, if you have a custom class cc_1, and want to call uf_close(), the typical code would be:

cc_1 l_nvo_1
l_nvo_1 = CREATE cc_1
l_nvo_1.uf_Close()

Whenever you are finished with the class, you can destroy it:

DESTROY l_nvo_1

Parent and This

If you create a standard user object, you can use the reserved words Parent and This, similar to a standard control. For example, if you write Close(Parent) for the clicked event of a CommandButton type user object, clicking on it would close the window. This will happen even if you open the user object dynamically with OpenUserObject() or OpenUserObjectWithParm().

User Object Events

In custom and C++ class user objects, only "Constructor" and "Destructor" events are available. In Custom/external visual user objects, Drag & Drop events are also available.

You can't trigger user object events that are declared in the user object painter. For example, say you have an user event ue_1, and you placed an user object uoc_1, in a window w_1, and named the user object as uo_1.

If you call TriggerEvent(uo_1, "ue_1") from any of the window's events, it won't be executed, even though there was no compiler error. You can only trigger custom user object's events only if you declare the events in the window painter.

In the above example, you can't declare ue_1 for uoc_1, because ue_1 is already declared in the user object Painter. The   solution for this would be to define functions in the user object Painter.

Suppose, you declare uf_close_parent() in the user object painter and when you call uf_close_parent() from the cb_1 clicked event,  it closes the window that contains this user object.

Unlike custom user objects, script for External type user objects events, written in the user objectPainter, can be triggered from the window.
HomePrevious Lesson: Custom Class
Next Lesson: Summary

Copyright © 1996 - 2006 HamaraShehar.com Pvt. Ltd. All Rights Reserved.
Domain Registration, Website Design, Website Hosting by HamaraShehar.com