Friday, April 29, 2011

This blog has been moved

Due some technical problems, I decided to move this blog to new address at

This blog will still exist, but for the new post will be posted at new blog address above.

Thank you

Thursday, April 28, 2011

Create Object Programmatically with Powerbuilder - Part 1

In Powerbuilder, we can create an object programmatically, means that you can create whenever you need or conditionally.

In this first part, I trying to explain how to create "static" picture object when user clicking the button. Static mean that we only create the object, without script associated inside the object. The function that will be used it's called: openuserobject

For detail explanation of openuserobject function, please see the official help of Powerbuilder. 

First, create a button, and type this follow script inside Clicked event.
picture p_2  // declare the picture variable
p_2 = create picture  // create the picture object

p_2.x = 100  // x position of the object
p_2.y = 100  // y position of the object
p_2.height = 250 // height value of the object
p_2.width = 250 // with value of the object
p_2.picturename = "redalert.bmp" // name of the picture inc full path

parent.openuserobject( p_2, "p_2", 100, 100) // ok, let's create the object


Wednesday, April 27, 2011

Click and Drag with Powerbuilder

This article will show you how to make an object to be click and drag capable in Powerbuilder. In this case, I'm using Powerbuilder 9.0 and Picture Object. In this version, I found DragAuto property in the list of the picture property, one that I can't found in version 6.5. I'm not sure, since when Sybase added this property.

The Drag Auto property determines whether PowerBuilder puts the control into drag mode automatically. If the property is enabled, when the user clicks the control and starts dragging it, PowerBuilder puts the control in drag mode. Clicking the control triggers a DragDrop event, not a Clicked event.

If Drag Auto is not enabled, then when the user clicks the control, PowerBuilder does not put the control in drag mode. You have to call the Drag function to put the control into drag mode.

In the Window, put 1 Picture object, and set the name of the file, and turn on the DragAuto option, in other tabs of property, and named it as p_1

Add the following script in p_1's clicked event

At the p_1's dragleave event, put this following script:
this.x = parent.pointerx( ) - (this.width / 2)
this.y = parent.pointery( ) - (this.height / 2)

And finally, at p_1's dragdrop event, add this following script: