About   -   Contact   -   Purchase   -   Search   -   What's New

Datawindow Buttons
This tip was submitted by Sameer Kulkarni.

The Datawindow in PowerBuilder is a great tool. However, one problem with them is that they do not provide command buttons. Here is a simple trick to have command buttons in datawindows.

Let's assume we have to place a 'Apply' command button: Place a text object reading 'Apply' on the datawindow in design painter. Give 3-D raised border to the object. Make sure the object has some name, say 'apply_t'. Now, write following code in the Clicked event of the datawindow control containing the datawindow object in question:

this.Modify ("apply_t.Border = '5'") // 3-D lowered border

Next, declare a user event for the datawindow control and associate it with Windows event wm_mouseup (i.e., pbm_mouseup). Let's call this event as 'we_mouseup'. Place following code in event we_mouseup:

this.Modify ("apply_t.Border = '6'") // 3-D raised border
IF Pos( this.GetObjectAtPointer(), "apply_t" ) > 0 THEN
// Your processing for command button click goes here.

With this, you can give different colors to the button's background and text too! You can also have custom fonts. To have a PictureButton, use a picture object (say a bmp) in the same way text object is used above. For text on the PictureButton place a text object with transparent background on the top of the picture object.

This trick will work equally well if you want to place colored command buttons on a window; with the only difference that you will have to write the code in a static text control's events.

In case of a grid datawindow, sometimes users are given the facility to sort by a column by clicking on its header. Same trick can be used there for the header's text object to simulate the 'real' buttony effect.


Top of Page

Legal Notice

Ken Howe 2011