Académique Documents
Professionnel Documents
Culture Documents
PowerBuilder®
Version 6.0
DC00000-01-
00000-
00
October
1997
Copyright © 1991-1997 by Sybase, Inc. All rights reserved.
This publication pertains to Sybase 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.
To order additional documents, U.S. and Canadian customers should call Customer Fulfillment at (800) 685-8225, fax (617) 229-9845.
Customers in other countries with a U.S. license agreement may contact Customer Fulfillment via the above fax number. All other
international customers should contact their Sybase subsidiary or local distributor. 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 Sybase, Inc.
Sybase trademarks can be viewed at the Sybase trademarks page at http://www.sybase.com/detail?id=1011207. Sybase and the marks listed
are trademarks of Sybase, Inc. ® indicates registration in the United States of America.
Java and all Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. 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.
Sybase, Inc., One Sybase Drive, Dublin, CA 94568.
About This Book
Subject This book describes two PowerBuilder interfaces that tool vendors can use
to integrate their applications with PowerBuilder. The interfaces are:
♦ PowerBuilder Test A set of OLE interfaces that allow an external
program to examine the properties of PowerBuilder applications,
DataWindow objects, and RichTextEdit controls
♦ PBSCC A set of standard functions that PowerBuilder calls in a
DLL implemented by a source control vendor
The book provides the information needed to write programs that work
with PowerBuilder in these areas.
Audience This book is for tool vendors who are developing applications that work
with PowerBuilder. The information provided is not needed to develop
PowerBuilder applications.
Test tool vendors can use PowerBuilder Test to look inside a
PowerBuilder application and examine the values of object properties.
Source control vendors can use the SCC specification and the information
in this book about its PowerBuilder implementation to write source
control provider DLLs. Source control systems that implement this
standard automatically make their source control systems accessible to
PowerBuilder users, as well as any other development environment that
uses the SCC specification.
iii
CH A PTE R 1 PowerBuilder Test OLE
Interfaces
About this chapter This chapter describes the PowerBuilder Test OLE interfaces with
reference documentation for the properties and methods. Visual Basic
code examples show how to use the OLE interfaces in a program.
FOR INFO Since some of the methods are similar to PowerBuilder
functions, you can get more information about how to use the functions
in the PowerScript Reference.
Contents
Topic Page
Using the PowerBuilder Test interfaces 1
PowerBuilder.Test 7
PowerBuilder.Test_DW 12
PowerBuilder.Test_RTE 21
Constraints You must use a tool other than PowerBuilder to program for this interface.
1
Using the PowerBuilder Test interfaces
Because of the design of OLE, you can’t reliably connect to the PowerBuilder
Test interface from another PowerBuilder program. There is no way to specify
which application you will connect to. The system connects to the first instance
of the interface it finds, which may well be your test application instead of the
application being tested. PowerBuilder provides other techniques for
communicating information between PowerBuilder programs.
You can use any other programming tool that lets you connect to an OLE
interface. The examples in this introduction are in Visual Basic.
Connecting to an To use an interface, you must connect to it. In Visual Basic, call the
interface CreateObject function:
Set MainObj = CreateObject("PowerBuilder.Test")
If MainObj Is Nothing Then
MsgBox "could not create 'Test' server"
Exit Sub
End If
Which interfaces do The three PowerBuilder Test interfaces are independent. You can connect to
you need? any interface that is installed in the system registry and use its functionality
without connecting to another.
However, if you don’t want to register the RichTextEdit or DataWindow
interfaces, you can use the PowerBuilder Test function ObjectFactory to
connect to an unregistered interface.
The first call to ObjectFactory uses the class ID for the Test_DW interface:
Dim MainObj As Object
Dim bRet As Boolean
Dim TestObj As Object
2
Chapter 1 PowerBuilder Test OLE Interfaces
This call to ObjectFactory uses the programmatic identifier for the interface:
bRet = MainObj.ObjectFactory(0,
"PowerBuilder.Test_DW", TestObj)
Getting version When you connect to the PowerBuilder.Test interface, you can find out the
information PowerBuilder version of the program being tested.
To get the full version number as a float, query the Version property. In this
code, Text1 is a textbox:
Dim VerFloat As Single
Dim Success As Boolean
VerFloat = MainObj.Version
Text1 = "Version " + Str$(VerFloat)
Getting window To access a PowerBuilder object, you need its system handle. On Windows NT
handles and Windows 95, you call the external functions FindWindow and
FindWindowEx. The declarations for Windows NT look like this:
Declare Function FindWindow Lib "USER32"
Alias "FindWindowA"
(ByVal lpClassName As Any,
ByVal lpWindowName As Any)
As Long
3
Using the PowerBuilder Test interfaces
As Long
You may have to traverse a hierarchy of windows to get the one you want. This
sample code finds the MDI frame, then the client area, and then the sheet to get
the DataWindow control on the sheet. Each FindWindow call uses the handle
from the previous one. The handle for the DataWindow is stored in the
efSource text box as hexadecimal string. Text1 and Text2 are also textboxes:
Dim hwndDW As Long
Dim hwndFrameTop As Long
Dim hwndFrame As Long
PowerBuilder window In the Windows operating system, all elements on the screen are windows
classes themselves and have classes and handles. They may or may not have a title,
which serves as the window’s name. When you call FindWindow, you can
identify a window by its class or its name.
As an example, in one build of PowerBuilder 6.0, objects had these class
names:
Object Class name
Window, MDI frame, and MDI sheet FNWND60
4
Chapter 1 PowerBuilder Test OLE Interfaces
Testing a RichTextEdit This code finds a window handle for a RichTextEdit control, connects to the
control RichTextEdit interface, initializes the RTE control, and calls the
GetInsertionPoint and SetSelection functions. Text1 and Text2 are textboxes.
RTEObj is a global variable:
Dim RTEObj As Object
If hwndRTE = 0 Then
Exit Sub
End If
5
Using the PowerBuilder Test interfaces
MyBool = RTEObj.Init(hwndRTE)
Text1 = "Init returned " + Str$(MyBool)
MyLong = RTEObj.LineCount
Text2 = "Line Count Is " + Str$(MyLong)
fl = 2
fc = 3
tl = 5
tc = 6
If RTEObj Is Nothing Then
Exit Sub
End If
Testing a The code for a DataWindow is similar: it finds a handle for a DataWindow
DataWindow control control, connects to the Test_DW interface, initializes the DataWindow
control, and calls the Describe method. Text1 and Text2 are textboxes:
Dim DWObj As Object
6
Chapter 1 PowerBuilder Test OLE Interfaces
MyBool = DWObj.Init(hwndDW)
Text1 = MyBool
Text2 = DWObj.Describe(
"DataWindow.Bands DataWindow.Objects")
PowerBuilder.Test
The PowerBuilder.Test interface provides basic version information for the
PowerBuilder application being tested. You can also use it to access the
DataWindow and RichTextEdit interfaces if you don’t want to rely on those
interfaces being registered.
7
IsPowerBuilderObject
Properties
Property Data type Description
Version float (Read-only) The version of
PowerBuilder
Methods
Data type
Method returned Description
IsPowerBuilderObject BOOL Reports whether an object is a
PowerBuilder object
IsPowerBuilderObject
Description Reports whether the object handle is a reference to a PowerBuilder object.
Argument Description
Object An object handle
Return value BOOL. Returns TRUE if the object handle refers to a PowerBuilder object.
8
Chapter 1 PowerBuilder Test OLE Interfaces
ObjectClassName
Description Reports the class of the object.
Argument Description
Object An object handle
Return value String. Returns the name of the object’s class. If Object is not a PowerBuilder
object, ObjectClassName returns an empty string.
Usage An object’s class is the PowerBuilder object definition for that object. The
returned string is the name of the class definition as saved in the PBL.
ObjectFactory
Description Creates a PowerBuilder Test interface without relying on the interface being
installed in the system registry. This is useful for future custom interfaces,
which wouldn’t be installed automatically in the system registry.
Argument Description
WindowObject The object handle for a window that you want to use with
the interface
9
ObjectIUnknown
Argument Description
InterfaceID A string whose value is either a Class ID or a
programmatic identifier for a PowerBuilder Test interface
Values for programmatic identifiers are:
♦ PowerBuilder.Test_DW
♦ PowerBuilder.Test_RTE
Values for COM class IDs are:
♦ TypeLibrary: LIBID_LIBPBTEST = {9537EB50-
52CC-11D0-9945-080009AC61A9}
♦ BaseTest: IID_IPBTEST = {9537EB51-52CC-11D0-
9945-080009AC61A9}
♦ DataWindow: IID_IPBTEST_DW = {9537EB52-
52CC-11D0-9945-080009AC61A9}
♦ RichTextEdit: IID_IPBTEST_RTE = {9537EB53-
52CC-11D0-9945-080009AC61A9}
Interface An IDispatch variable that will hold the handle to the
returned interface
Usage You can call ObjectFactory to get an interface for accessing a DataWindow or
a RichTextEdit control instead of calling your language’s method for
connecting to an object. Calling ObjectFactory is necessary when the
individual interfaces are not installed in the system registry.
To get an interface to an OLE object in a PowerBuilder window, call
ObjectIUnknown.
ObjectIUnknown
Description Gets the IUnknown interface for an OLE object in a PowerBuilder window.
Argument Description
Object The object handle of the OLE object for which you want
an interface
10
Chapter 1 PowerBuilder Test OLE Interfaces
Usage Use ObjectIUnknown when you want to call methods and set properties of an
OLE object. The caller must release this interface when done.
This method does not give you access to the methods and properties of
PowerBuilder objects.
VersionDetails
Description Reports version information about a PowerBuilder application, including
version number, internal build number, and the operating system for which it
was built.
Argument Description
VersionMajor A long variable to which PowerBuilder Test will assign
the major version number of the PowerBuilder application
server
For example, for PowerBuilder 5.0, VersionMajor is 5
VersionMinor A long variable to which PowerBuilder Test will assign
the minor version number of the PowerBuilder application
server
For example, for PowerBuilder 5.0.03, VersionMinor is 0
MaintLevel A long variable to which PowerBuilder Test will assign
the maintenance release number of the PowerBuilder
application server
For example, for PowerBuilder 5.0.03, MaintLevel is 3
BuildNumber A long variable to which PowerBuilder Test will assign
the build number of the PowerBuilder application server.
Applicable only to beta versions of PowerBuilder
MiscFlags A long variable in which PowerBuilder Test will set bits
to tell you more about the PowerBuilder version. See
Usage below
Return value BOOL. Returns TRUE if you are connected to a valid PowerBuilder
application server.
11
PowerBuilder.Test_DW
Usage To get the major and minor version numbers as a float value (for example,
PowerBuilder 5.0), use the Version property instead of the VersionDetails
method.
The meanings of the bit settings in the MiscFlags argument are:
Hex value Meaning of flag is SET
0000.0001 Debug build of PowerBuilder Virtual Machine
PowerBuilder.Test_DW
The PowerBuilder.Test_DW interface provides information about data and
focus in a DataWindow control in a PowerBuilder application. You can change
the current row and mark rows as selected. You can examine but can’t change
data. The Describe method gives access to the internal properties of the
DataWindow object.
PowerBuilder.Test_DW must be registered in the system registry unless you
connect via the ObjectFactory function of the PowerBuilder.Test interface.
When you install PowerBuilder or use the deployment kit, all the OLE
interfaces are registered automatically and each time you run PowerBuilder the
interfaces are reregistered.
12
Chapter 1 PowerBuilder Test OLE Interfaces
Properties
Property Data type Description
BandAtPointer string (Read-only) The name of the band in
which the pointer is currently located
and the row number associated with
the band. The two values are separated
by a tab (~t). The value has the format:
bandname~trow
FOR INFO For a list of band names
and the row associated with a band, see
the GetBandAtPointer function in the
PowerScript Reference
Methods
Data type
Method returned Description
Describe string Reports the values of properties of a
DataWindow object and objects within
the DataWindow object
13
Describe
Data type
Method returned Description
GetChild BOOL Provides an object reference to a child
DataWindow or to a report in a
composite DataWindow
Describe
Description Reports the values of properties of a DataWindow object and objects within the
DataWindow object. You can also evaluate expressions using values in a
specific row in the DataWindow.
Argument Description
Propertylist A string whose value is a blank-separated list of the
properties whose values you want. A property takes the
format objectname.property
14
Chapter 1 PowerBuilder Test OLE Interfaces
Return value string. Returns a string that includes a value for each property or Evaluate
function in Propertylist. A newline character (~n) separates each item.
Usage Although you can request several properties in a single call to Describe, doing
so can result in a very complex string with several levels of nested quotes. For
debugging purposes, it is easier to request one property at a time.
FOR INFO For more information about the format of Propertylist, the return
value, or evaluating an expression, see the Describe function in the
PowerScript Reference.
FOR INFO For information about the properties of objects within a
DataWindow object, see the DataWindow Reference.
GetChild
Description Provides a reference to a child DataWindow or to a report in a composite
DataWindow.
Argument Description
ChildName A string whose value is the name of the column
containing the child DataWindow or the name of the
report in the composite DataWindow
ChildDW A variable in which you want GetChild to put the
reference to the child DataWindow
Return value BOOL. Returns TRUE if it succeeds and FALSE if an error occurs.
Usage To specify the current DataWindow (the one that contains the child
DataWindow) before calling other methods, call Init.
To examine the child DataWindow, use the reference returned by GetChild as
the argument for the Init method. This resets the current DataWindow to be the
child DataWindow. Then call other Test_DW methods for the child
DataWindow.
FOR INFO For more information about child DataWindows, see the
GetChild function in the DataWindow Reference.
15
GetItemDateTime
GetItemDateTime
Description Gets data whose type is DateTime from the primary buffer of the DataWindow.
Syntax BOOL GetItemDateTime ( long Row, long Col, REF long Year, REF long
Month, REF long Day, REF long Hour, REF long Minute, REF long
Second, REF long MicroSeconds )
Argument Description
Row A long value specifying the row for which you want the
DateTime value
Col A long value specifying a column whose data type is
DateTime
Year A long variable in which to store the 4-digit year of the
DateTime value
Month A long variable in which to store the month of the
DateTime value. Month is a value from 1 to 12
Day A long variable in which to store the day of the DateTime
value. Day is a value from 1 to 31
Hour A long variable in which to store the hour of the
DateTime value. Hour is a value from 0 to 23
Minute A long variable in which to store the minutes of the
DateTime value. Minute is a value from 0 to 59
Second A long variable in which to store the seconds of the
DateTime value. Second is a value from 0 to 59
MicroSecond A long variable in which to store the year of the DateTime
value. MicroSecond is a value from 0 to 999,999
Return value BOOL. Returns TRUE for success and FALSE if an error occurs—for
example, if the column is the wrong data type.
Usage To specify the current DataWindow before calling other method, call Init.
FOR INFO For similar PowerBuilder functionality, see the GetItemDate,
GetItemDateTime, and GetItemTime functions in the PowerScript
Reference.
GetObjectAtPointer
16
Chapter 1 PowerBuilder Test OLE Interfaces
Description Reports the object and row number under the pointer.
Argument Description
DWObject A string variable in which to store the name of the object
under the pointer and its row number, separated by a tab
character (~t). The string has the format:
name~trow
Return value BOOL. Returns TRUE if it succeeds and FALSE if an error occurs.
Usage To specify the current DataWindow before calling other methods, call Init.
The PowerBuilder function GetObjectAtPointer has similar functionality to
this PowerBuilder Test method.
FOR INFO For information on the rows associated with bands (and therefore
with objects in those bands), see the GetBandAtPointer function in the
PowerScript Reference.
Init
Description Sets up the PBTEST_DW interface for the DataWindow you want to examine.
Argument Description
DWObject An object reference to a DataWindow
Return value BOOL. Returns TRUE if DWOBject is a valid DataWindow and the
initialization was successful. Returns FALSE if an error occurs.
Usage To specify the current DataWindow before calling other methods, call Init. You
can call Init as often as needed to change the DataWindow being examined.
IsSelected
17
SaveAs
Argument Description
Row A long value specifying the row that you want to test
Return value BOOL. Returns TRUE if Row is selected FALSE if it is not selected. If Row is
greater than the number of rows in the primary buffer or is 0 or negative,
IsSelected returns FALSE.
Usage Call Init to specify the current DataWindow before calling other methods.
More than one row can be highlighted. A selected row is not the same as the
current row, which is the row that has focus. To find out the current row, use
the Row property.
FOR INFO For similar PowerBuilder functionality, see the IsSelected
function in the PowerScript Reference.
SaveAs
Description Saves the contents of a DataWindow control in the format you specify.
18
Chapter 1 PowerBuilder Test OLE Interfaces
Argument Description
SaveAsType A long value specifying the format of the saved data. Use
values of the enum tagDW_SAVEAS:
♦ DW_SAVEAS_EXCEL
♦ DW_SAVEAS_TEXT
♦ DW_SAVEAS_CSV
♦ DW_SAVEAS_SYLK
♦ DW_SAVEAS_WKS
♦ DW_SAVEAS_WK1
♦ DW_SAVEAS_DIF
♦ DW_SAVEAS_DBF2
♦ DW_SAVEAS_DBF3
♦ DW_SAVEAS_SQL
♦ DW_SAVEAS_CLIPBOARD
♦ DW_SAVEAS_PS
♦ DW_SAVEAS_WMF
Values are similar to the PowerBuilder enumerated data
type SaveAsType. For more information about the values,
see the SaveAs function in the PowerScript Reference
IncludingHeadings A long value indicating whether to include the
DataWindow’s column headings at the beginning of the
file. Values are:
♦ 0 Do not include headings
♦ Nonzero Include headings
FileName A string whose valid is the name of the file in which to
save the contents
Return value BOOL. Returns TRUE if it succeeds and FALSE if an error occurs.
Usage To specify the current DataWindow before calling other methods, call Init.
FOR INFO For similar PowerBuilder functionality, see the SaveAs function
in the PowerScript Reference.
SelectedRow
19
SelectRow
Description Reports the number of the next highlighted row after a specified row in a
DataWindow control.
Argument Description
Row A long variable in which to store the location of the row
after which you want to search for the next selected row
Return value BOOL. Returns TRUE if it succeeds and FALSE if an error occurs.
Usage To specify the current DataWindow before calling other methods, call Init.
SelectedRow begins its search after the specified row. It doesn’t matter whether
row itself is selected.
FOR INFO For similar PowerBuilder functionality, see the GetSelectedRow
function in the PowerScript Reference.
SelectRow
Description Highlights or unhighlights rows in a DataWindow. You can select all rows or a
single row. SelectRow does not affect which row is current. It does not select
rows in the database.
Argument Description
RowNumber A long value specifying the number of the row you want
to select or deselect. Rows are numbered from 1 to the
total number of rows. To specify all rows, specify 0
State A long value specifying whether to select the row. Values
are:
♦ 0 Unhighlight the row
♦ Nonzero Highlight the row
Return value BOOL. Returns TRUE if it succeeds and FALSE if an error occurs.
Usage To specify the current DataWindow before calling other methods, call Init.
FOR INFO For similar PowerBuilder functionality, see the SelectRow
function in the PowerScript Reference.
20
Chapter 1 PowerBuilder Test OLE Interfaces
SetAllEvents
Description Enables all PowerScript events for the current DataWindow.
Return value BOOL. Returns TRUE if it is successful and FALSE if an error occurs.
Usage To specify the current DataWindow before calling other methods, call Init.
PowerBuilder.Test_RTE
The PowerBuilder.Test_RTE interface provides information about the content
and insertion point in a RichTextEdit control or RichTextEdit DataWindow in
a PowerBuilder application. You can get and set the insertion point or mark a
text selection. You can get the text in the line containing the insertion point and
you can change the current band (header, body, or footer).
PowerBuilder.Test_RTE must be registered in the system registry—unless you
connect via the ObjectFactory function of the PowerBuilder.Test interface.
When you install PowerBuilder or use the deployment kit, all the OLE
interfaces are registered automatically and each time you run PowerBuilder the
interfaces are reregistered.
Properties
Property Data type Description
LineCount long (Read-only) The number of lines of
text in the RichTextEdit control
Methods
Data type
Method returned Description
GetCharFormat BOOL Reports the text formatting in effect at
the insertion point
21
GetCharFormat
Data type
Method returned Description
GetCurrentBand BOOL Finds out whether the current band is
detail, header, or footer
GetCharFormat
Description Reports the character formatting in effect at the insertion point.
Syntax BOOL GetCharFormat ( REF long OldRetVal, REF long Mask, REF long
Effects, REF long Height, REF long Color, REF long CharSet, REF long
PitchAndFamily, REF string FaceNameAsString )
Argument Description
OldRetVal A long variable in which to store the return value from an
internal message
Mask A long variable. The mask value is always 0
Effects A long variable in which to store an effects value
22
Chapter 1 PowerBuilder Test OLE Interfaces
Argument Description
Height A long variable in which to store the text height. The
value is as described for the Windows SDK LOGFONT
structure
Color A long variable in which to store the text color as an RGB
color value
CharSet A long variable in which to store the character set. The
value is as described for the Windows SDK LOGFONT
structure
PitchAndFamily A long variable in which to store additional font
information. The value is as described for the Windows
SDK LOGFONT structure
FaceNameAsString A string variable in which to store the font name. The
value is as described for the Windows SDK LOGFONT
structure
Return value BOOL. Returns TRUE if it succeeds and FALSE if an error occurs.
Usage FOR INFO For similar PowerBuilder functionality, see the GetTextColor and
GetTextStyle functions in the PowerScript Reference. (In PowerBuilder, you
can’t find out the font and font size programmatically.)
GetCurrentBand
Description Finds out what band in the RichTextEdit control or DataWindow contains the
insertion point.
Argument Description
BandAttributes A long variable in which to store a number identifying the
current band. Compare the value to the values of the enum
tag RTE_BAND:
♦ RTEBAND_DETAIL
♦ RTEBAND_HEADER
♦ RTEBAND_FOOTER
Return value BOOL. Returns TRUE if it succeeds and FALSE if an error occurs.
23
GetInsertionPoint
GetInsertionPoint
Description Reports the line and character column of the insertion point.
Argument Description
Line A long variable in which to store the number of the line
containing the insertion point
CharCol A long variable in which to store the number of the
character just after the insertion point, where the first
character is 1. When the insertion point is at the beginning
of a line, CharCol is set to 1
Return value BOOL. Returns TRUE if it succeeds and FALSE if an error occurs.
Usage For similar PowerBuilder functionality, see the Position function in the
PowerScript Reference.
GetLine
Description Gets the text of a entire line in a RichTextEdit control or DataWindow.
Argument Description
LineNumber A long value specifying the number of a line
TextOfLine A string variable in which to store the text of the specified
line
Return value BOOL. Returns TRUE if it succeeds and FALSE if an error occurs.
Usage For similar PowerBuilder functionality, see the TextLine, SelectTextLine, and
SelectedText functions in the PowerScript Reference.
GetSelection
24
Chapter 1 PowerBuilder Test OLE Interfaces
Description Gets the start and end position of selected text in a RichTextEdit control or
DataWindow.
Syntax BOOL GetSelection ( REF long FromLine, REF long FromColumn, REF
long ToLine, REF long ToColumn )
Argument Description
FromLine A long variable in which to store the number of the line in
which the selection starts
FromColumn A long variable in which to store the number in the line of
the first character in the selection
ToLine A long variable in which to store the number of the line
where the selection ends
ToColumn A long variable in which to store the number in the line of
the character before which the selection ends
Return value BOOL. Returns TRUE if it succeeds and FALSE if an error occurs.
Usage If text is selected, the insertion point can be at the beginning or the end of the
selection. For example, if the user dragged down to select text, the insertion
point is at the end.
Selection or insertion point To find out whether there is a selection or just
an insertion point, check the values of the last two arguments. If ToLine and
ToColumn are set to 0, then there is no selection but only an insertion point.
If there is a selection and you want the position of the insertion point, call
GetInsertionPoint instead.
Insertion point and end of selection discrepancy The position of an
insertion point at the end of the selection and the actual end of selection can
differ. When reporting the position of selected text, the positions are
inclusive. GetSelection reports the first line and character and the last line
and character that are selected. When reporting the position of the insertion
point, GetInsertionPoint identifies the character just after the insertion point.
FOR INFO For similar PowerBuilder functionality, see the Position function
in the PowerScript Reference.
Init
25
LineLength
Description Sets up the PBTEST_RTE interface for the control you want to examine. The
control must be a RichTextEdit control or a DataWindow control containing a
DataWindow object with the RichTextEdit presentation style.
Argument Description
RTEObject An object reference to a RichTextEdit control or
DataWindow
LineLength
Description Reports the number of characters in the line containing the insertion point in a
RichTextEdit control or DataWindow.
Argument Description
LineNumber A long value specifying the number of the line for which
you want the length
LineLength A long variable in which to store the number of characters
in the line
Return value BOOL. Returns TRUE if it succeeds and FALSE if an error occurs.
Usage For similar PowerBuilder functionality, see the SelectLine and SelectedLength
functions in the PowerScript Reference.
SetCurrentBand
26
Chapter 1 PowerBuilder Test OLE Interfaces
Description Sets the current band in a RichTextEdit control or DataWindow. The bands are
detail (the main text area), header, and footer.
Argument Description
Band A long value specifying the band. Use values of the enum
tag RTE_BAND:
♦ RTEBAND_DETAIL
♦ RTEBAND_HEADER
♦ RTEBAND_FOOTER
Return value BOOL. Returns TRUE if it succeeds and FALSE if an error occurs.
Usage Call GetCurrentBand to find out the current band before you change it with
SetCurrentBand. When you change the current band, you should reset it after
your processing is complete. Otherwise, the user’s view of the RichTextEdit
content could be disrupted.
SetInsertionPoint
Description Puts the insertion point at a particular line and character column in a
RichTextEdit control or DataWindow.
Argument Description
Line A long value specifying the number of the line that will
contain the insertion point
CharCol A long value specifying the number of the character that
will follow the insertion point. The first character on a line
is 1
Return value BOOL. Returns TRUE if it succeeds and FALSE if an error occurs.
Usage To put the insertion point in a different band, call SetCurrentBand first.
FOR INFO For similar PowerBuilder functionality, see the SelectText
function in the PowerScript Reference.
27
SetSelection
SetSelection
Description Selects a range of text in a RichTextEdit control or DataWindow.
Argument Description
FromLine A long value specifying the number of the line in which
the selection starts
FromCharCol A long value specifying the number in the line of the first
character in the selection. The number of the first
character in a line is 1
ToLine A long value specifying the number of the line in which
the selection ends
ToCharCol A long value specifying the number in the line of the last
character in the selection
Return value BOOL. Returns TRUE if it succeeds and FALSE if an error occurs.
28
CH A PTE R 2 PBSCC Interface Function
Reference
About the chapter This chapter documents functions that the PowerBuilder SCC interface
calls and the values that PowerBuilder passes to the source control
provider so that you can implement those functions in a source control
provider DLL.
Contents
Topic Page
About the PBSCC interface 29
Microsoft header file Source control in PowerBuilder implements the Microsoft Common
required Source Code Control Interface Specification, Version 0.00.0823.
Powersoft has conformed to this interface specification as closely as
possible. For this reason, vendors who wish to write SCC provider DLLs
for PowerBuilder need to license the SCC.H header file from Microsoft.
For future versions of PowerBuilder, Powersoft and its CODE partners
may decide to augment this specification to provide additional
functionality.
Calling convention The functions in the SCC provider DLL must use the _cdecl calling
convention.
29
How PBSCC works
SCC functions called The SCC functions that the PowerBuilder PBSCC interface calls in response
by PowerBuilder to the user’s source control commands are listed in "Source control commands
that trigger SCC function calls" on page 31.
The values that PBSCC passes to the functions are documented in "Functions
for the SCC interface" on page 35.
SCC functions not These functions specified in the SCC API are not currently implemented in the
implemented in PowerBuilder PBSCC interface:
PBSCC
SccGetVersion
SccRename
SccProperties
SccQueryInfo
SccGetEvents
SccAddFromScc
SccSetOption
These functions are called in the PowerBuilder 6.0 version of PBSCC only:
SccDiff
SccRunScc
User options The user has several options for source control. The user can connect:
♦ To PowerBuilder native source control, which checks objects in to and
out of PBLs but does not maintain a source control archive
♦ Via a PowerBuilder interface to a small set of source control vendors
♦ Via SCC to any source control vendor that supports the SCC interface
The PowerBuilder SCC interface provides the most robust source control with
the best synchronization between the source control archive and PowerBuilder
PBLs.
How the user The user connects to an SCC source control system by selecting
connects via SCC to Source>Connect and choosing SCC API from the list of vendors. Then if more
source control
than one SCC provider is installed, the user chooses from a list of providers.
PowerBuilder gets the list of SCC providers from the system registry.
30
Chapter CHAPTER 2 PBSCC Interface Function Reference
PowerBuilder uses a data value associated with the provider (called the
ProviderRegKey) to look up the path for the provider DLL, stored in an entry
labeled SCCServerPath.
After the user has established a source control connection for an application
object, PowerBuilder saves that information and connects automatically
without prompting the user. The user can change the configuration by choosing
Source>Configuration.
Source>Connect SccGetProjectPath
SccOpenProject
SccGetCommandOptions
Source>Configuration SccCloseProject
SccUninitialize
SccInitialize
SccGetProjectPath
SccOpenProject
SccGetCommandOptions
Source>Check In SccCheckin
31
How PBSCC works
Source>Connect SccGetProjectPath
SccOpenProject
SccGetCommandOptions
Source>Configuration SccCloseProject
SccUninitialize
SccInitialize
SccGetProjectPath
SccOpenProject
SccGetCommandOptions
Source>Check In SccCheckin
32
Chapter CHAPTER 2 PBSCC Interface Function Reference
[Library] section of PowerBuilder stores information about the most recently used source control
PB.INI system in PB.INI:
[Library]
SourceVendor=vendorname
Configuration file for In the configuration file, the ProviderRegKey value names a subkey in the
the application object system registry that identifies where to locate the provider’s SCC DLL. A
section named for the provider identifies the parameters of the user’s last
connection for the application.
For example, the PBSCC configuration file might have values like these for the
user’s last connection to a project called scctest using Visual SourceSafe:
[PBSMS]
SMSInterface=SCC
ProviderRegKey=Software\Microsoft\SourceSafe
[SourceSafe]
UserID=pamm
ProjectName="$/scctest",JAAAAAAA
LocalPath=c:\pbls\srcctl
AuxProjPath=d:\vss,
33
How PBSCC works
When the provider If during initialization the provider has told PBSCC that it supports textout
supports textout (SCC_CAP_TEXTOUT), the provider can also call the PBSCC message
handler when an error occurs. This callback function stores a message in the
PBSCC trace log. PowerBuilder does not display this message to the user. It
always displays error messages based on the return values of SCC functions.
The syntax for the message handler is:
typedef LONG (*LPTEXTOUTPROC) (LPSTR, LONG);
Argument Description
LPSTR A string whose value is the error message text. The
string should not contain carriage return or linefeed
characters and should be null-terminated
LONG A long identifying the type of message. Values are:
♦ SCC_MSG_INFO
♦ SCC_MSG_WARNING
♦ SCC_MSG_ERROR
♦ SCC_MSG_STATUS
♦ SCC_MSG_DOCANCEL
♦ SCC_MSG_STARTCANCEL
♦ SCC_MSG_STOPCANCEL
34
Chapter CHAPTER 2 PBSCC Interface Function Reference
Steps for error When the provider supports textout These are the steps for error message
message handling processing when the provider supports textout:
1 PowerBuilder calls an SCC function implemented by the provider.
2 An error occurs during the provider’s processing.
3 The provider may or may not display an error message. Because
PowerBuilder also displays a message, it is better for the provider not
to.
4 The provider calls the PBSCC textout callback function. The pointer to
the function was passed to the provider when PBSCC called
SccOpenProject.
5 PowerBuilder puts the message passed to it by the callback function
into its trace log and returns SCC_MSG_RTN_OK to the provider.
6 The provider returns an error code from the function called in step 1.
7 PowerBuilder performs error processing based on the error code, which
can include displaying a message to the user.
When the provider doesn’t support textout The steps for handling error
messages are the same except for the omission of steps 4 and 5 (because
there is no callback function).
35
SccAdd
SccGetCommandOptions
SccGetProjPath
SccHistory
SccInitialize
SccOpenProject
SccPopulateList
SccRemove
SccRunScc
SccUncheckout
SccAdd
Description Called when the user highlights one or more objects and selects
Source>Register in the Library painter. PBSCC calls it once for each
highlighted object.
Syntax SCCRTN SccAdd (void *pvContext, HWND hWnd, LONG nFiles, LPSTR
*lpFileNames, LPSTR lpComment, LONG *pfOptions, void *pvOptions);
Argument passed
to provider Data Type Value
pvContext void * Provider’s context structure, allocated
during initialization
36
Chapter CHAPTER 2 PBSCC Interface Function Reference
Argument passed
to provider Data Type Value
pfOptions LONG * Array of LONGs. Array length is 1. The
value of pfOptions[0] is usually
SCC_FILETYPE_TEXT, meaning the file
to be registered is an ASCII text file
For DataWindow object, the value is
SCC_FILETYPE_AUTO
Return value SCCRTN. The SCC provider should return one of the following values:
Value Meaning
SCC_OK Success
Usage PowerBuilder behavior PowerBuilder does not display a dialog box when
registering an object, so there is no opportunity for the user to specify a
comment or advanced options. PBSCC passes the object comment stored in
the PBL.
Before calling SccAdd, PBSCC creates a temporary file containing the object
that the provider will register in the archive. The file is in the local project path
directory specified in the configuration. After SccAdd finishes and control
returns to PBSCC, PBSCC deletes the temporary file.
SccCheckin
37
SccCheckin
Description Called when the user highlights one or more objects in the Library painter and
selects Source>Checkin. It is called once for each highlighted object.
Return value SCCRTN. The SCC provider returns one of the following values:
Value Meaning
SCC_OK Success
38
Chapter CHAPTER 2 PBSCC Interface Function Reference
Value Meaning
SCC_I_OPERATIONCANCELED Operation canceled before completion
SccCheckout
Description Called when the user highlights one or more objects in the Library painter and
selects Source>Checkout. It is called once for each highlighted object.
39
SccCheckout
Argument
passed to
provider Data type Value
pvContext void * Provider’s context structure, allocated by
the provider during initialization
Return value SCCRTN. The SCC provider returns one of the following values:
Value Meaning
SCC_OK Success
40
Chapter CHAPTER 2 PBSCC Interface Function Reference
Value Meaning
SCC_E_FILEISLOCKED File is locked
Usage The same check-out comment applies to the all the objects the user checks out
at one time. To have different check-out comments, the user must highlight one
object and select Source>Checkout, repeating the sequence for all objects.
PowerBuilder behavior PowerBuilder detects whether the provider
supports check-out comments from the
SCC_CAP_COMMENTCHECKOUT flag set from SccInitialize. If the
provider doesn’t support checkout comments or advanced options, the
CheckOut Object(s) dialog box is not displayed.
When the user chooses Source>Checkout, PowerBuilder prompts for the name
of the work library into which it will copy the object. Then it displays the
CheckOut Object(s) dialog box so that the user can specify a comment and
advanced options.
If the user clicks the Advanced button, PBSCC calls SccGetCommandOptions
with the ppvOptions argument pointing to a NULL value. The SCC provider
can display an advanced settings dialog box, store the user’s settings in a data
structure, and put the address of the data structure in the location specified by
the ppvOptions argument.
Finally, PBSCC calls SccCheckout for each object the user highlighted,
passing the address of the advanced options data structure in pvOptions.
SCC provider actions The provider writes a file containing the object
stored in the archive using the path and filename specified in the
lpFileNames array.
The provider can take into account the advanced settings stored in its own data
structure passed in pvOptions.
Additional PowerBuilder behavior When SccCheckout returns SCC_OK,
PBSCC imports the temporary file written by the provider into the
registration PBL, then copies the object to the work PBL and sets the check-
out status in both PBLs. Then it deletes the temporary file.
If PBSCC cannot import the object into the registration PBL, it calls
SccUncheckout to clear the check-out status in the archive so that the archive
and the PBLs remain in sync.
41
SccDiff
SccDiff
Description Called when the user highlights an object in the Library painter and selects
Source>Compare Differences.
Available in PowerBuilder 6.0 or later.
Return value SCCRTN. The SCC provider returns one of the following values:
Value Meaning
SCC_OK Success
42
Chapter CHAPTER 2 PBSCC Interface Function Reference
SccGet
Description Called when PBSCC needs a copy of an object in the source control archive.
PBSCC calls SccGet in these situations:
♦ When the user selects Source>Synchronize
♦ When the user selects Take in the PBSCC Registration Directory dialog
box
Syntax SCCRTN SccGet (void *pvContext, HWND hWnd, LONG nFiles, LPSTR
*lpFileNames, LONG fOptions, void *pvOptions);
Argument
passed to
provider Data type Value
pvContext void * Provider’s context structure, allocated by
the provider during initialization
43
SccGetCommandOptions
Argument
passed to
provider Data type Value
pvOptions void * SCC provider-specific options. Always
NULL
Return value SCCRTN. The SCC provider returns one of the following values:
Value Meaning
SCC_OK Success
Usage PowerBuilder behavior When SccGet returns, PBSCC copies the file
written by the SCC provider into the work PBL or a PBL designated by the
user.
In PowerBuilder, the fOptions flags SCC_GET_ALL and
SCC_GET_RECURSIVE will not be used. lpFileNames will always be a list
of one file.
PowerBuilder will not create a temporary file in the local project path before
calling SccGet.
SccGetCommandOptions
44
Chapter CHAPTER 2 PBSCC Interface Function Reference
Description Called during initialization to find out what advanced options the SCC provider
supports. When a user invokes a command that supports advanced options,
PBSCC calls it again so that the SCC provider can display the dialog boxes for
those options.
Return value SCCRTN. The SCC provider returns one of the following values:
Value Meaning
SCC_OK Success
45
SccGetCommandOptions
Value Meaning
SCC_E_ISCHECKEDOUT Operation cannot be performed on a
checked-out file
46
Chapter CHAPTER 2 PBSCC Interface Function Reference
SccGetProjPath
Description Called when PBSCC connects and the current PowerBuilder application object
has not been configured for source control.
47
SccGetProjPath
Argument passed
to provider Data type Value
lpProjName LPSTR The project name provided by the user in
the PowerBuilder Configuration dialog
box. If the value is blank, the provider
can prompt for a project name and return
the name in this buffer
PowerBuilder expects the provider to
create a new project if the named project
does not exist
Usage If the user connects and the application has not been configured for source
control, PowerBuilder prompts the user to provide project information.
PBSCC passes the information the user provides to SccGetProjPath. If the
information is incomplete, the provider can display its own dialog boxes to get
the information. If the specified project doesn’t exist, the provider should
create the project, displaying its own dialog boxes to get information from the
user as needed.
48
Chapter CHAPTER 2 PBSCC Interface Function Reference
For each application object that has been configured for source control,
PowerBuilder stores information about the associated source control project.
When the user connects, PBSCC passes this information to SccOpenProject. It
doesn’t call SccGetProjPath.
SccHistory
Description Called when the user highlights one or more objects in a PBL and selects
Source>Registration Report.
Syntax SCCRTN SccHistory (void *pvContext, HWND hWnd, LONG nFiles, LPSTR
*lpFileNames, LONG fOptions, void *pvOptions);
Argument
passed to
provider Data type Value
pvContext void * Provider’s context structure, allocated by
the provider during initialization
Return value SCCRTN. The SCC provider returns one of the following values:
Value Meaning
SCC_OK Success
49
SccInitialize
Value Meaning
SCC_I_RELOAD SCC provider modified the local version
of the file. IDE should reload the file.
SccInitialize
Description Called when PowerBuilder connects to the source control system and when the
user changes projects—for example, by choosing another application object.
50
Chapter CHAPTER 2 PBSCC Interface Function Reference
Argument passed to
provider Data type Value
ppvContext void ** The SCC provider can allocate a
context structure for a connection and
store the address of this work
memory at this location. All
subsequent SCC function calls will
pass back the Context pointer
Return value SCCRTN. The provider returns one of the following values:
Value Meaning
SCC_OK Success
51
SccOpenProject
Value Meaning
SCC_E_NONSPECIFICERROR Nonspecific failure
If the provider returns any value other than SCC_OK, PowerBuilder displays
an error message to the user and tells the Library painter that connecting to
source control failed.
SccOpenProject
Description Called after initialization to tell the provider to open a project.
52
Chapter CHAPTER 2 PBSCC Interface Function Reference
53
SccOpenProject
Argument
passed to
provider Data type Value
lpTextOutProc LPTEXTOUTPROC If the provider reported support for
textout (SCC_CAP_TEXTOUT), a
pointer to the PBSCC callback
function for handling messages
If textout isn’t supported,
lpTextOutProc is NULL
FOR INFO For more about error
message handling and the callback
syntax, see "Error message handling"
on page 34
Return value SCCRTN. The provider returns one of the following values:
Value Meaning
SCC_OK Success
54
Chapter CHAPTER 2 PBSCC Interface Function Reference
SccPopulateList
Description Called when the user selects Source>Registration Directory in the Library
painter. PBSCC prompts the provider to build the list of registered objects so
that PowerBuilder can display the list to the user.
55
SccPopulateList
Argument
passed to
provider Data type Value
fOptions LONG Set to 0, which means the value in
lpFileNames is a file, not a directory
Return value SCCRTN. The SCC provider returns one of the following values:
Value Meaning
SCC_OK Success
56
Chapter CHAPTER 2 PBSCC Interface Function Reference
SccRemove
Description Called when the user highlights one or more objects in the Library painter and
selects Source>Clear Registration. It is called once for each highlighted object.
The provider should remove all registration information for the object from the
source control project.
57
SccRunScc
Argument
passed to
provider Data type Value
fOptions LONG Command flags. Set to
SCC_REMOVE_KEEP
Return value SCCRTN. The SCC provider returns one of the following values:
Value Meaning
SCC_OK Success
Usage PowerBuilder behavior For each selected item, PowerBuilder prompts the
user to confirm the clearing. Then if confirmed, PowerBuilder calls
SccRemove for that object.
There is no dialog box for clearing a registration, so there is no opportunity for
the user to specify advanced options.
SCC Provider actions The provider should remove all version information
from the source management system for the object identified in the
lpFileNames array.
SccRunScc
Description Called when the user selects Source>SCC Administration.
58
Chapter CHAPTER 2 PBSCC Interface Function Reference
Return value SCCRTN. The SCC provider returns one of the following values:
Value Meaning
SCC_OK Success
SccUncheckout
Description Called when the user highlights one or more objects in the Library painter and
selects Source>Clear Checkout Status. It is called for each highlighted object.
The provider should mark the object as checked in.
Also called when a check-out fails because the checked-out file cannot be
imported into the PBL.
59
SccUncheckout
Return value SCCRTN. The SCC provider returns one of the following values:
Value Meaning
SCC_OK Success
60
Chapter CHAPTER 2 PBSCC Interface Function Reference
Usage PowerBuilder does not display a dialog box for Clear Checkout Status.
Therefore, there is no opportunity for the user to specify advanced options.
61
SccUncheckout
62