Advanced PowerBuilder

HomePrevious Lesson: Displaying About Window
Next Lesson: Minimizing Application When Idle

Displaying a Background Logo

This section gives you concepts. Don't write the code given in this section. Displaying a background logo looks like a simple thing, but it requires some thought. You might think that, to display a background logo, you could paint it in the MDI Frame window itself. However, as we've already discussed, this would disable PowerBuilder's automatic resizing of the client area. When you take into account the fact that a logo is typically centered, you may not be left much room to resize the sheets.

Instead, you could paint the company logo in a window, opening this window before opening the login window. However, this doesn't solve the problem, because the Open() function makes the window independent and when you open another sheet, this window goes out of the MDI frame window's area. When the logo window is opened with OpenSheet(), PowerBuilder displays the title bar, minimize and maximize icons. In other words, the window is given functionality that draws attention to it, rather than fading it into the background.

A Response window wouldn't work either, because the user can't work with the application as long as the response window is open.

This only leaves a Child window or a Popup window. Only in these two type of windows you disable all the attributes, such as border, titlebar, control menu, min/max icons, close icon, enable property, menu name, etc... If you open a window with OpenSheet() function, the window name will be displayed under one of the menu bar items, which allows it to be selected by the user. We don't want this to happen, so we have to make do with the Open() function.

Create a new window and turn off all its attributes except the visible attribute and make it a Child window. Paint the company logo on the window.

Save the window as w_logo and in the open event script for w_mdi_frame window, call this logo window with the Open() function. Try running the application, you'll see that this does work.

However, there are still couple of problems. Whenever MDI Frame is resized, w_logo window and the logo within it are not resized accordingly. Also, if you open other sheets in the MDI Frame, they won't be visible because, the child window will always be on top of any opened window.

We can solve the first problem by writing script for the resize event of the MDI Frame, but this won't solve the second. The best solution is to display the logo when we open the MDI main window and then turn its visible property off when we open a sheet. We can then check for open sheets, after we run the File > Close menu option script. If there aren't any, turn the visible property back on. We would also need to add the following line to the start of the script for 'Module > Product Master Maint' menu option:
w_logo.visible = FALSE

We can then create a new user event ue_check_for_active_sheets at the MDI window level and assign it a custom Event ID. We then write the following code for this event:
Window l_Sheet
l_Sheet = GetActiveSheet( This)
If not IsValid( l_Sheet) Then w_logo.visible = True

and call this event from the File > Close menu script using:
PostEvent( ParentWindow, "ue_check_for_active_sheets")
HomePrevious Lesson: Displaying About Window
Next Lesson: Minimizing Application When Idle