Tech Articles


Simple User Preference/Customization Service for PowerBuilder Applications


User Preference/Customization Service

Users nowadays expect applications to remember settings and customizations between sessions.  This saves time, frustration, and improves productivity.

Here is an easy to implement, user customization service you can add to your Powerbuilder applications which stores configuration information in a database.  This gives the added benefit of portability to the users as nothing is stored in ini files or the registry.  It is PFC based but, with minor modifications, could be un-coupled from that if desired.

The main object is the n_cst_dbinifile NVO.  The export of it can be found towards the end of the article

Note the export makes use of the PFC n_cst_inifile and n_base NVOs but this can be stripped out if desired.

The service allows for default values to be set up and used if the user does not have their own set up (or when you give them the option to undo all their changes).  The service also keeps itself updated by retrieving the datastore at an interval of your choosing.

Read more

Data-Driven Column Gradient Bar


As of PowerBuilder 11.5, DataWindow columns have been able to have background gradients. In that gradients can be data-driven by expressions, this tip will review how columns can emulate bar graphs.

For this example, I’ve created a DataWindow object that displays sales orders by sales rep and I’ve created a computed field that displays each rep’s quantity of orders as a percentage compared to the total count of orders for all sales reps.

DataWindow Painter - Computed Field

To have the column’s background gradient behave as a bar in a bar graph, first institute the background gradient itself. Here I’ve chosen a horizontal gradient that will be blue in color.

Read more

Resizing a Response Window or User Object


Here is a technique you can use to resize a response window or userobject as needed. It makes use of the GetWindowLong and SetWindowLong Windows API methods. The oldest reference I found to this is from Eric Aling back in 2000.

In a nutshell, you are changing the border around the object to one which Windows allows to be resized. What's even nicer about this is the standard resize events are triggered so you can reposition/change objects within the window as well (PFC resize service for example). From Eric's original post:

"The Get function retrieves the complete definition of the window in 
a big long variable. All the bits in this long value describe the window. 
So there are bits for the type of border (which indicates if a window is 
resizable), menu, colors etc.etc. We can modify this long value, altering 
the design of the window. Using the SetWindowLong() we update the window with 
our specific modifications."

I used this in ancestor code of a userobject I use to create visible panels within the main window.

Read more

Window Object Information Service


Here is an easy to implement service geared towards developers who are working on complex, many layered applications. In its basic form it shows the current window object, which pbl it is located in, all the various ancestors of the window, their pbl locations, all datawindows and datawindow objects on the window, and the sql statements for those datawindow objects.

The only dependency in the window is the pfc resize service. This can easily be stripped out if needed.

To implement the service, add the following to the window/ancestor window event (rbuttondown for example):

openwithparm(w_window_info,THIS)


The screenshot is an example output.

Window Information Service Window

 

Read more

PowerBuilder 'Gotcha' - PixelsToUnits


From the 12.5 Powerbuilder Help on this method:
Converts pixels to PowerBuilder units. Because pixels are not usually square, you also specify whether you are converting the pixels' horizontal or vertical measurement.

Syntax

PixelsToUnits ( pixels, type )

Argument Description
pixels An integer whose value is the number of pixels you want to convert to PowerBuilder units.
type A value of the ConvertType enumerated datatype value indicating how to convert the value:
· XPixelsToUnits! - Convert the pixels in the horizontal direction.
· YPixelsToUnits! - Convert the pixels in the vertical direction.
Return value

Integer. Returns the converted value if it succeeds and -1 if an error occurs. If any argument's value is null, PixelsToUnits returns null.

Read more

Reading MS Outlook Items


Here is some code which reads data from Outlook (2007 was tested) into Powerbuilder. You basically need to create a window with a multiline edit and a button on it. Put this into the clicked event of the button.

To run it, open Outlook, select something (email message, task, etc.) then click the button on your PB window. There are many, many more methods and properties you have access to from PB via OLE to Outlook. The MSDN reference online is a big help

integer li_rc
long ll_itemcount, ll_i
oleobject lole_item, lole_outlook, lole_exp, lole_selecteditems
string ls_subject, ls_from, ls_to, ls_body, ls_msg
lole_outlook = CREATE oleobject
lole_exp = CREATE oleobject
lole_selecteditems = CREATE oleobject
li_rc = lole_outlook.ConnectToNewObject("outlook.application")
lole_exp = lole_outlook.ActiveExplorer()
// Outlook has to be running
If IsNull(lole_exp) THEN
    Messagebox('Outlook Error','Is Outlook currently running?')
    GOTO cleanup
END IF
li_rc = lole_exp.class
// caption is window name like "Inbox - Microsoft Outlook" or "Calendar - Microsoft Outlook"
ls_subject = lole_exp.caption

lole_selecteditems = lole_exp.selection
ll_itemcount = lole_selecteditems.count
Read more

Grid datawindow object with variable number of columns


Here is a way to build a grid datawindow which contains columns corresponding to an unknown number of data elements. You could use this approach in creating a project schedule, inventory location system, baseball box score, or any number of other examples. My example assumes the minimum number of columns to be four.

This create grid event returns a string.

long    ll_columns, ll_count, ll_pos
string ls_errors, ls_sql, ls_dw_presentation, ls_dw_syntax, ls_find, ls_name, ls_mod_string
// base presentation information
ls_dw_presentation =    "style( type=Grid                          &
            Horizontal_spread = 25 )            &
     datawindow( units=1                       &
             Color= 16777215)              &
     column( Font.Face='Arial'         &
         Font.Height=-9                    &
         Font.Weight=400)                  &
         text(   Font.Face='Arial' &
         Font.Height=-9                    &
         Font.Weight=400                   &
             Border=6)"

Read more

Find Articles by Tag

Encryption API Application Class Jenkins Design Branch & Merge NativePDF SQL Server Windows OS CoderObject Platform OLE Event Handler SnapDevelop Database Object Import Resize iOS Database Table Schema TreeView Validation PowerBuilder (Appeon) Configuration RichTextEdit Control OAuth 2.0 SVN Event Web API PBDOM Data File Web Service Proxy Bug UI Modernization Elevate Conference Debug Performance Repository SDK Text Database Painter GhostScript ODBC DragDrop RibbonBar PowerServer Web Menu C# Trial XML PowerBuilder Compiler Azure Export Icon Filter Open Source Error JSONGenerator Service Deployment Android Oracle Syntax Source Control PowerBuilder Automated Testing SOAP SnapObjects License PDFlib UI Transaction InfoMaker PowerServer Mobile RESTClient RibbonBar Builder Window JSON Database Table Data OAuth WinAPI PDF DLL Database Outlook Debugger UI Themes Linux OS Migration Interface DataType Script PostgreSQL ODBC driver Expression Testing Variable DevOps Sort MessageBox Windows 10 Icons WebBrowser TLS/SSL IDE Encoding .NET Std Framework PFC Charts SqlModelMapper Import JSON 32-bit Authentication TFS SQL REST Excel Database Profile Event Handling Stored Procedure Database Connection Model Debugging DataWindow Authorization .NET Assembly DataWindow JSON Export JSON CI/CD PowerScript (PS) .NET DataStore Array Database Table Mobile CrypterObject Git 64-bit COM External Functions Graph SqlExecutor BLOB Source Code TortoiseGit PostgreSQL HTTPClient Messagging JSONParser Installation OrcaScript ActiveX