If you have been using the Subversion (SVN) source code control system for your PowerBuilder applications for a while, you have likely been using an SCC API implementation client (such as PBSCC Proxy, PushOK, etc.) to connect PowerBuilder to SVN. If you are considering switching to the native SVN interface provided by PowerBuilder then you probably do not want to lose the history of all the changes you made during all those years of development. Although this is not covered in the PowerBuilder documentation, it is relatively simple to do.
Tech Articles
PowerBuilder Equivalents to Windows API Datatypes
At some point in your PowerBuilder career, you will need to call a Windows API (or WinAPI, for short) function. The WinAPI specifications are heavily dependent on type definitions created in C/C++ via the #define preprocessor directive. The use of type defintions helps the readability of Windows code, but it unfortunately and effectively hides the actual underlying datatype - making it difficult for you to correctly code the PowerBuilder external function declaration needed to call the API function.
Some time ago I published a four-part series of PowerBuilder tutorials that explain the ins and outs of interfacting PowerBuilder apps with the Windows API, but I realize the many developers are very busy and do not have the luxury of sufficient spare time needed to read that much material. In case you are interested and have the time, I have included URLs to those tutorials at the end of this article.
This article consists of two tables. The first table lists many of the most commonly-seen WinAPI type definitions and their PowerBuilder equivalents. The second table lists the PowerBuilder datatypes and their WinAPI equivalents, if any. For your convenience, I am also providing the URLs to several useful resources you may find helpful when coding external function declarations.
Common Windows API Type Definitions to PowerBuilder Datatypes
The following table maps many of the most commonly-used WinAPI type definitions to their PowerBuilder equivalents:
WinAPI Type Definition or Datatype | Equivalent PB Datatype | Comment |
BOOL | Boolean | Boolean (True/False) value. A 4-byte integer in Windows. A 2-byte integer in PowerBuilder. PB automatically promotes/demotes the value to the appropriate datatype when it is used as an argument in an external function call. |
BOOLEAN | Byte | Boolean (True/False) value. An 8-bit, unsigned integer. NOTE: Not the same datatype as BOOL, yet it is also used for True/False values. |
BYTE | Byte | An 8-bit, unsigned integer. |
Byte Array (block of memory | Blob | A block of memory is typically referenced by a pointer (the address of the first array element) in Windows. |
CONST** | Constant** | A directive that conveys to the compiler that the value is to remain unchanged during execution. (** => NOT a datatype) |
double (C/C++) | Double | A basic C/C++ language datatype, not a WinAPI-defined type definition. |
DWORD | UnsignedLong or ULong | A 32-bit unsigned integer. |
FLOAT | Real | Rarely used in WinAPI, but included here for completness. |
HANDLE | Longptr | A generic handle (ID number) to an undetermined Windows resource. |
HBITMAP | Longptr | A handle to a bitmap. |
HBRUSH | Longptr | A handle to a brush. |
HDC | Longptr | A handle to a device context. |
HDROP | Longptr | A handle to an internal drop structure, used in drag/drop operations. |
HFILE | Longptr | A handle to a file. |
HFONT | Longptr | A handle to a font. |
HICON | Longptr | A handle to an icon (you should be starting to see a pattern by now, I hope). |
HINSTANCE | Longptr | A handle to an instance (same as HMODULE). |
HMENU | Longptr | A handle to a menu. |
HMODULE | Longptr | A handle to a module (same as HINSTANCE). |
HMONITOR | Longptr | A handle to a display monitor. |
HRESULT | Long | A return code used by COM interfaces. NOTE: This is NOT a Windows handle, although its name would imply that it contains a Windows handle. |
HWND | Longptr | A handle to a window or a control. All controls are implemented as subclassed windows, so a handle for a control is actually a handle to a window. |
INT | Long | A signed 32-bit integer (NOT a PowerBuilder Int, which is 16-bits long. |
INT16 | Integer (or Int) | A signed 16-bit integer. |
INT32 | Long | A signed 32-bit integer. |
INT64 | LongLong | A signed 64-bit integer. |
INT8 | -none- | A signed 8-bit integer. NOTE: The PowerBuilder Byte datatype is an unsigned 8-bit integer. |
INT_PTR | Longptr | A signed integer (32-bit or 64-bit, depending on the process/app bitness. Used in Windows for pointer arithmetic. |
LANGID | Integer (or Int) | A language identifier. |
LONG | Long | A signed 32-bit integer. |
LONGLONG | LongLong | A signed 64-bit integer. |
LONG_PTR | Longptr | A signed integer (32-bit or 64-bit, depending on the process/app bitness. Used in Windows for pointer arithmetic. |
LONG32 | Long | A signed 32-bit integer. |
LONG64 | LongLong | A signed 64-bit integer. |
LPARAM | Longptr | A Windows event message parameter. |
LPCSTR | Longptr | A pointer to a constant, null-terminated string (array) or ANSI characters. |
LPCVOID | Longptr | A pointer to a constant of undetermined datatype. |
LPCWSTR | Longptr | A pointer to a constant, null-terminated string (array) of Unicode ("Wide") characters. |
LPVOID | Longptr | A pointer to a value of undetermined datatype. |
LPDWORD | Longptr | A pointer to a DWORD (an unsigned 32-bit integer). |
LPWORD | Longptr | A pointer to a WORD (an unsigned 16-bit integer). |
LPWSTR | Longptr | A pointer to a null-terminated string (array) of Unicode ("Wide") characters. |
PVOID | Longptr | A pointer to a value of undetermined datatype. |
QWORD | -none- | An unsigned 64-bit integer. NOTE: The PowerBuilder LongLong datatype is a signed 64-bit integer. |
SHORT | Integer (or Int) | A signed 16-bit integer. |
UINT | UnsignedLong (or ULong) | An unsigned 32-bit integer. |
ULONG | UnsignedLong (or ULong) | An unsigned 32-bit integer. |
ULONGLONG | -none- | An unsigned 64-bit integer. NOTE: The PowerBuilder LongLong datatype is a signed 64-bit integer. |
USHORT | UnsignedInt (or UInt) | An unsigned 16-bit integer. |
VOID | Any | A value of undetermined datatype. Means "returns no value" when describing a function's return value. |
WCHAR | Character (or Char) | A Unicode ("Wide") character. |
WORD | Integer (or Int) | A signed 16-bit integer. |
WPARAM | Longptr | A Windows event message parameter. |
Please be aware that WinAPI type definitions can be "nested." For example, HICON is defined as HANDLE. HANDLE is defined as PVOID. PVOID is defined as a pointer to any datatype. Therefore, HICON is a pointer, which can be either a 32-bit integer or a 64-bit integer, depending on the bitness of the application/process... and this translates to a Longptr in PowerBuilder.
Here is a URL to online documentation describing these and additional various WinAPI type definitions:
https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types
The following URL is a staring point for documentation on Windows API functions and structures:
https://learn.microsoft.com/en-us/windows/win32/apiindex/api-index-portal
Many WinAPI functions indicate success/failure status via the function's return value. In the event of a failed call, an internal error number may be set within the Windows operating system. You can obtain this numeric error code via the GetLastError WinAPI function, but deciphering what an error code value means can be problematic. If you have Visual Studio installed, you can examing the header file named "winerror.h" to find the name of nearly all error codes, or you can instead visit the following URL:
https://learn.microsoft.com/en-us/windows/win32/debug/system-error-codes
PowerBuilder Datatypes to Windows Type Datatypes and Type Definitions
The following table maps the PowerBuilder datatypes to their WinAPI equivalents:
PowerBuilder Datatype | Size (Bytes) | Equivalent WinAPI Type Definition or Datatype | Comment |
Any | 8 or 12 | n/a | An internal PowerBuilder structure. Its size depends on the target compilation bitness. When used in a structure object, an Any assumes the size and characteristics of the argument parameter is represents. There is no WinAPI equivalent. |
Blob | 4 or 8 | BYTE array | An array of type BYTE (i.e., a pointer), so the size depends on the target compilation bitness. |
Boolean | 2 | BOOL | BOOL is a 4-byte integer in WinAPI, but a PowerBuilder Boolean is 2 bytes. PB automatically promotes/demotes the value to the appropriate datatype when it is used as an argument in an external function call. |
Character (or Char) | 2 | WCHAR | Unicode character. "W" stands for "wide," i.e., Unicode. |
Date | 4 or 8 | -none- | A pointer to an internal PowerBuilder structure, so the size depends on the target compilation bitness. There is no WinAPI equivalent. |
Datetime | 4 or 8 | -none- | A pointer to an internal PowerBuilder structure, so the size depends on the target compilation bitness. There is no WinAPI equivalent. See the note that follows this table. |
Decimal | 8 | -none- | There is no WinAPI equivalent. |
Double | 8 | double (C/C++) | |
Integer (or Int) | 2 | SHORT | |
Long | 4 | INT or Long | |
LongLong | 8 | LONGLONG | |
Longptr | 4 or 8 | LONG_PTR | A signed 32-bit or 64-bit integers. Its size depends on the target compilation bitness. |
Real | 4 | FLOAT | Rarely used in WinAPI. |
String | 4 or 8 | LPWSTR | A null-terminated array of Unicode characters (i.e., a pointer), so the size depends on the target compilation bitness. |
Time | 4 or 8 | -none- | A pointer to an internal PowerBuilder structure, so the size depends on the target compilation bitness. There is no WinAPI equivalent. |
UnsignedInteger (or UnsignedInt or UInt) | 2 | USHORT or WORD | |
UnsignedLong (or ULong) | 4 | DWORD |
Note:
The SYSTEMTIME structure in the WinAPI specifies a date and time, using individual members for the month, day, year, weekday, hour, minute, second, and millisecond, which is roughly equivalent to the PowerBuilder Datetime datatype. There are no supplied functions to convert values between the two formats, but they can be created by a PB developer relatively easily.
Interfacing PowerBuilder Applications to Window API Functions
There is a series of PowerBuilder tutorials online in the Appeon Community that will help you master the intricacies of interfacing PB apps with Windows API functions. You can access this series of tutorials via the following URLs:
PowerBuilder Icons
Update on 23-OCT-2024: The icons have apparently been moved to a new home:
https://www.appeon.com/sites/default/files/pictures/Downloads/CodeSample/PB10_Icons.zip
https://www.appeon.com/sites/default/files/pictures/Downloads/CodeSample/Silk Icons.zip
https://www.appeon.com/sites/default/files/pictures/Downloads/CodeSample/WinXP Icons.zip
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Earlier, one of our members asked about obtaining a set of the PB Classic icons. I've got those, along with two other sets of Icons available for your use. These icons sets are:
Tile Menu Style using Datawindow Object
Updated sample with added features from pbdev.id blog
Have you ever wanted Windows Tile Menu Style on your application? this datawindow object can give you way to have it.
Just add row data to set Image, Text and size of the tile.
REST Enhancements in PowerBuilder 2019
REST support was added to PowerBuilder in 2017 R2 and enhanced in 2017 R3. PowerBuilder 2019 contains additional significant enhancements to REST support, including the following:
- RetrieveOne method – For REST methods return one row
- Submit method - sends request and returns data in one operation
- SetRequestHeader behavior modified
- GZIP compression handled automatically
- Send[Method]Request, where method can be Get, Put, Post, Patch, Delete
- Get and Set OAuth token methods
- Get and set JWT token methods
Free My GUI! - Multi-Threading in PowerBuilder
In this follow-up to the article titled “’Haunted Apps’ – How to Avoid Ghost (Unresponsive) Windows”, you’ll learn about the multi-threading capabilities available to PowerBuilder applications and how multi-threading can be used to perform tasks that typically freeze the application’s Graphical User Interface (GUI). Multi-threading can be utilized for many purposes, but this discussion will focus primarily on the use case of long-running data retrieval requests.
This article covers what you need to know in order to get started using multi-threading in PowerBuilder. A new example application that can be easily customized to test multi-threaded data retrieval in your development environment(s) is now available in the PowerBuilder section of CodeXchange. An expanded, but slightly earlier version of this article is included in the example application’s download package that explains the objects and code in detail.
How to create an application from object source code files using PowerBuilder
PowerBuilder can create an entire application from the object source files stored in a source code control system without relying on existing PBLs. This has been public knowledge for years, but since I cannot find the article anymore where I read about this for the first time, and since I still see people saying the opposite, I decided to put together this short how-to guide hoping that this information will become searchable.
If someone knows the link to the original article, I will be happy to include it here or even replace this article with the link.