Tech Articles


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

Trapping DataWindow Control System Commands


Perhaps you’ve enabled the titlebar and control menu of a DataWindow control.  You may even want the users to be able to minimize/maximize and reposition the control at runtime.

DataWindow Control Properties

Now you’d like to trap when the user interacts with the control in this fashion in order to execute some logic when they do. Perhaps you’d like to know when/if the user closes the DataWindow control.

Read more

The dwSyntax Tool


Thank you Sandy Barletta!

Just after the earth began to cool (I think it was in the PB3 time frame), I discovered the DWSyntax tool created by Sandy.

‘Round about that time I had been exporting DataWindow objects (this was before “edit source” folks) in order to get functional syntax for my dwModify() calls. Lo’ and behold I discovered this nifty GUI that would allow me to browse the dwDescribe(), dwModify(), SyntaxFromSQL() argument syntax for any DataWindow item or for the DataWindow object itself.

Fast forward to the present day. Let’s say you need to change the expression of a computed field at runtime, much as I illustrated in another tip on dynamically “creating” DataWindow groups.

From the PowerBuilder IDE, open the “New” dialogue. Select the “Tool” tabpage, and then select the “DataWindow Syntax” item.

Image

 

Read more

Find Articles by Tag

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