PowerBuilder – Special Effects Popup

Posted on Monday, September 20th, 2010 at 8:40 pm in

A question came up on Tek-tips forum regarding creating a special effects popup window. These are the kind which come up from the bottom right corner of your display to tell you your virus data has been updated or some such important message. Many times these are also semi transparent and even go away after a set time period. This is what I came up with.

This is using PB 11.5.1.

Create a window of type main! with no titlebar. Set the transparency to 10, the OpenAnimation to Bottomroll! and the CloseAnimation to toproll!.

In my window I put a picturebutton with the small Red X bitmap, a static text control, and a datawindow. The datawindow object is a freeform external with a single string data element called ‘message_text’. A single instance variable is declared on the window (Long il_open).

In the Open Event

long ll_ScreenHt, ll_ScreenWid
long ll_row
environment le_env

// Get screen size from environment
GetEnvironment( le_env )

ll_ScreenHt = PixelsToUnits( le_env.ScreenHeight, YPixelsToUnits! )
ll_ScreenWid = PixelsToUnits( le_env.ScreenWidth, XPixelsToUnits! )

// open in lower right corner
this.Move( ( ll_ScreenWid - this.Width ), ( ll_ScreenHt - this.Height ) )

ll_row = dw_1.insertrow(0)
dw_1.setitem(ll_row,'message_text','Here is a datawindow row')

Timer(1)

In the Timer Event

st_1.text = 'Timer Count: ' + string(il_open)

il_open ++

IF Mod(il_open, 2) = 0 AND il_open > 4 THEN
	THIS.Transparency = This.Transparency + 10
END IF
// close the window if no one is paying attention
If This.Transparency > 60 THEN
	event post close()
END IF

The Close Event:

Close(THIS)

And finally in the clicked event of the picture button:

Parent.event post close()

Updated March 2021

Top