Appeon Powerbuilder® 2017 DOCUMENT ID: DC37774-01-1700-01
Total Page:16
File Type:pdf, Size:1020Kb
Application Techniques Appeon PowerBuilder® 2017 DOCUMENT ID: DC37774-01-1700-01 LAST REVISED: June 2017 Copyright © 2017 by Appeon Limited. All rights reserved. This publication pertains to Appeon software and to any subsequent release until otherwise indicated in new editions or technical notes. Information in this document is subject to change without notice. The software described herein is furnished under a license agreement, and it may be used or copied only in accordance with the terms of that agreement. Upgrades are provided only at regularly scheduled software release dates. No part of this publication may be reproduced, transmitted, or translated in any form or by any means, electronic, mechanical, manual, optical, or otherwise, without the prior written permission of Appeon Limited. Appeon and other Appeon products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of Appeon Limited. SAP and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP and SAP affiliate company. Java and all Java-based marks are trademarks or registered trademarks of Oracle and/or its affiliates in the U.S. and other countries. Unicode and the Unicode Logo are registered trademarks of Unicode, Inc. All other company and product names mentioned may be trademarks of the respective companies with which they are associated. Use, duplication, or disclosure by the government is subject to the restrictions set forth in subparagraph (c)(1)(ii) of DFARS 52.227-7013 for the DOD and as set forth in FAR 52.227-19(a)-(d) for civilian agencies. Appeon Limited, 1/F, Shell Industrial Building, 12 Lee Chung Street, Chai Wan District, Hong Kong Contents About This Book ........................................................................................................................ xvii PART 1 SAMPLE APPLICATIONS CHAPTER 1 Using Sample Applications............................................................ 3 About the sample applications ......................................................... 3 Installing the sample applications .................................................... 3 Opening the sample applications ..................................................... 4 Using the Code Examples application.............................................. 4 Browsing the examples ............................................................. 5 Finding examples ...................................................................... 5 Running and examining examples ............................................ 6 PART 2 LANGUAGE TECHNIQUES CHAPTER 2 Selected Object-Oriented Programming Topics ........................ 11 Terminology review ........................................................................ 11 PowerBuilder techniques ............................................................... 13 Other techniques............................................................................ 16 CHAPTER 3 Selected PowerScript Topics....................................................... 21 Dot notation.................................................................................... 21 Constant declarations .................................................................... 25 Controlling access for instance variables....................................... 26 Resolving naming conflicts............................................................. 27 Return values from ancestor scripts............................................... 28 Types of arguments for functions and events ................................ 30 Ancestor and descendent variables ............................................... 31 Optimizing expressions for DataWindow and external objects ...... 33 Exception handling in PowerBuilder............................................... 34 Basics of exception handling................................................... 34 Application Techniques iii Contents Objects for exception handling support ................................... 35 Handling exceptions ................................................................ 36 Creating user-defined exception types.................................... 38 Adding flexibility and facilitating object reuse .......................... 40 Using the SystemError and Error events................................. 41 Garbage collection and memory management .............................. 42 Configuring memory management .......................................... 44 Efficient compiling and performance .............................................. 45 Reading and writing text or binary files .......................................... 45 CHAPTER 4 Getting Information About PowerBuilder Class Definitions...... 49 Overview of class definition information......................................... 49 Terminology............................................................................. 50 Who uses PowerBuilder class definitions................................ 52 Examining a class definition........................................................... 52 Getting a class definition object............................................... 53 Getting detailed information about the class ........................... 53 Getting information about a class's scripts.............................. 56 Getting information about variables......................................... 58 PART 3 USER INTERFACE TECHNIQUES CHAPTER 5 Building an MDI Application ......................................................... 63 About MDI ...................................................................................... 63 Building an MDI frame window....................................................... 66 Using sheets .................................................................................. 66 Providing MicroHelp ....................................................................... 68 Using toolbars in MDI applications................................................. 69 Customizing toolbar behavior.................................................. 69 Saving and restoring toolbar settings ...................................... 70 Sizing the client area...................................................................... 74 About keyboard support in MDI applications.................................. 77 CHAPTER 6 Managing Window Instances........................................................ 79 About window instances................................................................. 79 Declaring instances of windows ..................................................... 80 Using window arrays ...................................................................... 81 Referencing entities in descendants .............................................. 84 CHAPTER 7 Using Tab Controls in a Window.................................................. 87 About Tab controls ......................................................................... 87 iv PowerBuilder Contents Defining and managing tab pages ................................................. 88 Customizing the Tab control .......................................................... 91 Using Tab controls in scripts .......................................................... 94 Referring to tab pages in scripts.............................................. 94 Referring to controls on tab pages .......................................... 96 Opening, closing, and hiding tab pages .................................. 97 Keeping track of tab pages...................................................... 98 Creating tab pages only when needed.................................... 99 Events for the parts of the Tab control .................................. 100 CHAPTER 8 Using TreeView Controls ........................................................... 103 About TreeView controls .............................................................. 103 Populating TreeViews .................................................................. 106 Functions for inserting items ................................................. 107 Inserting items at the root level ............................................. 109 Inserting items below the root level ....................................... 109 Managing TreeView items............................................................ 111 Deleting items........................................................................ 113 Renaming items .................................................................... 114 Moving items using drag and drop ........................................ 115 Sorting items ......................................................................... 118 Managing TreeView pictures........................................................ 119 Pictures for items................................................................... 120 Setting up picture lists ........................................................... 122 Using overlay pictures ........................................................... 123 Using DataWindow information to populate a TreeView.............. 124 CHAPTER 9 Using Lists in a Window............................................................. 127 About presenting lists................................................................... 127 Using lists..................................................................................... 128 Using drop-down lists..................................................................