Tech Articles
- Details
- Written by Matthew Balent
- Category: PowerBuilder
- Hits: 3673
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.
- Details
- Written by Matthew Balent
- Category: PowerBuilder
- Hits: 1552
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.
- Details
- Written by Matthew Balent
- Category: PowerBuilder
- Hits: 1135
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.
- Details
- Written by Matthew Balent
- Category: PowerBuilder
- Hits: 1808
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
- Details
- Written by Matthew Balent
- Category: PowerBuilder
- Hits: 1755
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)"
- Details
- Written by John Strano
- Category: PowerBuilder
- Hits: 1543
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.
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.