14 users PowerBuilder study notes of custom objects

Tutorial links: https://wenku.baidu.com/view/9730d1c7aa00b52acec7ca05.html?re=view&rec_flag=default&sxts=1565141830016
Chapter user object 14:
1, where the object for the user: the user is the object encapsulates a set of related code and properties, to accomplish a specific function reusable object, the user object is generally common functions for performing,
when the application requires repeated use of certain characteristics should be defined user objects.

2, the role of the user object:
① expansion of the system of the original object function, increased use of new methods;
② create custom components highly reusable, re-use in one or more applications, reducing development and maintenance of the world, providing development efficiency;
③ the code embedded in other languages Powerbuilder application.

3, the user object advantages:
① avoid the different parts of the same or similar code written application function hassle, improves the maintainability of the application
② user objects can be grouped together a set of visual controls for use with short, control configuration, a complete application specific functions may be used where it is needed at any time
③ object provides the user with a consistent appearance configuration of a visual control of the process
④ user object can be packaged together with related functions
⑤ allow developers to extend the user object some PowerBuiler system objects (such as transaction objects) function.

4, the user object classification:
(1) visual user object (Visual User Object), such as buttons, edit boxes, etc. have the visual appearance of the application mainly to complete the exchange of information with the user's own
① standard visual user object (Standard Visual Object the user)
② customized visual user object (the user the custom the visual Object)
③ external visual user object (the user external the visual Object)
(2) user control class (class user Object), no screen forms, mainly for packaging and complete certain business logic.
Standard class user object ①
② custom class user object
class user object without visual component, create an instance of the code when used, the specific steps:
① described user object class types of variables, the object is created using the CREATE statement is a instance.
② can access the object in the whole of a variable domain, code attributes, event, function, just as the use of pre-defined objects (such as transaction processing objects SQLCA)
when the object is no longer in use ③, use the DESTROY statement to remove the Object to release the memory it occupies.
Example: u_datastore myhds // declare a variable of type u_datastore myDS
myDS = // create the CREATE u_datastore user object instance myDS
myds_DataObject = 'd_user_search' // with data window object class user object linking
myds.SetTransObject (SQLCA) // set the class transaction object used by the user object
ret = myds.Retrieve (math) // retrieves data
... // other processing required by the application
DESTROY myds // delete the user object after use, the release of memory

User object usually named "u_" prefix indicating control or user object instance typically "uo_" prefix.

4.1.1 standard visual user objects Standard Visual
is an extension of the existing controls PB, increasing the functionality required by the application on the basis of existing controls on basic functions. It inherited the original control various features, including the properties, events and functions.
Call triggering event or function statement:

System events are enumerated type: Clicked !, user-defined event strings: "u_key"

4.1.2, custom visual user objects Custom Visual
is more controls but the user object and combined into a whole, to complete certain functions and operations.
Visual user object size, position, and other properties of the control window can not be changed, can be modified to customize the visual user object drawing board.
When using custom code control window visual user control object, the syntax is: control the user object name + name + attribute or function, examples: uo_1.cb_ok.text = "OK" text properties for the control of cb_ok objects uo_1 assignment

4.1.3, external visual user objects External Visual
is actually written in other languages using third-party controls in PB application.

4.2.1 Standard user object class
inherits all system objects inside a feature, a function based on this modification (similar to a standard visual user object)
class user object without visual component, create an instance of its use in the code specific steps:
① described user object class type variable, a CREATE statement created instance of the object.
② can access the object in the whole of a variable domain, code attributes, event, function, just as the use of pre-defined objects (such as transaction processing objects SQLCA)
when the object is no longer in use ③, use the DESTROY statement to remove the Object to release the memory it occupies.
Example: u_datastore myhds // declare a variable of type u_datastore myDS
myDS = // create the CREATE u_datastore user object instance myDS
myds_DataObject = 'd_user_search' // with data window object class user object linking
myds.SetTransObject (SQLCA) // set the class user transaction object used by the object
ret = myds.Retrieve (math) // retrieve the data
... // other processing required by the application
DESTROY myds delete a user object after use // free memory
4.2.2 custom class user object
to customize class object is the user's own user design, the package does not need to process visual characteristics. These objects are not inherited from a PB object or control, fully customizable instance variables, functions, events implemented by the user through.
Customize the user visual objects only two predefined system events: Constructor and Destructor.
Delete user objects can only be achieved in the "Library" workspace.

调用触发事件或函数的语句:
Object_name.[Trigger|Post][Static|Dynamic] EVENT event_name([para_list])

object_name.TriggerEvent(event_name)
object_name.PostEvent(event_name)
系统事件是枚举类型:Clicked!, 用户自定义事件是字符串:"u_key"

 

Guess you like

Origin www.cnblogs.com/Bokeyan/p/11344387.html