The Splash Screen


We are finally ready for the splash screen. Many systems display a logo screen when they start that disappears after a couple of seconds. It's like a "hello" to the user . Here's how to build one of these splash screens. (You should breeze through this because it's very similar to the form you just created. We'll add the three things necessary for a new window: the window, a canvas, and then a data block.)

Go back to your friend Object Navigator and do the following:

  1. Make a new window called CWE1P_SPLASH.

  2. Highlight CANVAS , click on the green plus sign, and rename your new canvas "CWE1P_SPLASH_CANVAS".

  3. Click on Data Block and then the green plus sign, and select Build a new data block manually . Rename the new block "CWE1P_SPLASH_BLOCK".

Here's what your Object Navigator screen should look like:

graphics/13fig59.gif

Bear with me. Here are the next steps. Open the property palette of CWE1P_ SPLASH_CANVAS (under CANVAS ) and do the following:

  1. Make the title "GUERRILLA EXAMS".

  2. Go down a few lines to the Window Style property, click next to property title and select Dialog from the list.

  3. Make sure the value for Hide on Exit is "Yes".

  4. Change the value for Move Allowed , Resize Allowed , and Maximize Allowed to "No". We do not want the user to play with the screen when it appears, so we're shutting off those features.

  5. Center the screen by changing the X and Y positions to 120 and 100, respectively.

  6. Now you have to fix the canvas, so close out of this window and select CWE1P_SPLASH_CANVAS.

  7. Right-click and select Property Palette; change Width to 320 and Height to 200.

graphics/13fig60.gif

OK, you probably need a break, so take a short one, and then we'll get back to work.

Adding Image and Text to the Canvas

We now have to create a canvas that will have the graphical image and some text. There are some rules here, so just follow along and you'll be all set:

  1. Go to CWE1P_SPLASH_CANVAS and double-click on it so that it opens up in Layout Editor. Notice that there is a white border inside. The reason is that you set the size to 320 x 200, remember? This is the area you have to work with for your image. Don't go outside the white border!

  2. Pick the image item tool from the buttons on the left side, and draw a box inside the canvas that is just a little bit smaller than the canvas. You should have a big X within the white border on your canvas. (Make sure you pick the right tool. It looks like a projection screen with a blue picture on it.)

  3. Right-click on your new image area (say, in the middle of the big X), select the palette, and change the name to "CWE1P_SPLASH_IMAGE".

  4. Select Sizing Style (still in the property palette) and change it to "Adjust".

  5. Make sure the X and Y positions are set to 0.

  6. Change Height to 200 and Width to 320.

  7. Under Functional , change Sizing Style to "Crop".

  8. Close the property palette, staying in Layout Editor.

  9. Now add a small box at the bottom of the image area. You can put it anywhere you want because it will contain just a couple lines of copyright information. Select the text icon (the icon with the "abc" in it) and draw the box so that your canvas now looks like this:

    graphics/13fig61.gif

  10. Your last step will be to set the variables in the property palette for your new box, so position the cursor somewhere inside the box, right-click, select Property Palette , and make the following changes:

    • Name: CWE1P_SPLASH_ITEM

    • Item Type: Display item

    • Maximum Length : 500

    • Background Color : White

    • Font Name : Arial

Your canvas should now look like this:

graphics/13fig62.jpg

Displaying the Graphic

Now what you have is an area that can be used to display the splash image that you'll be loading with a trigger, and then hiding with another trigger. Isn't it amazing that something that will appear for only a few seconds has so many instructions?

Here we go. You'll be adding the PL/SQL code to grab and display the graphic and to fill in the little box at the bottom center:

  1. Select Tools Object Navigator and click on PRE-FORM under Triggers:

    graphics/13fig63.gif

  2. Now enter the code shown in the following screen shot and compile it (but don't exit yet!):

    graphics/13fig64.gif

Note

I can't stress this enough: Watch your syntax! The little things like single quotes, semicolons, and so forth will trip you up. I have sometimes spent a lot of time debugging, when all the problem turned out to be was a missing single quote at the end of 'hat.bmp. You will find that Forms will accept bad syntax, compile it, and run it for you, even though it is nonfunctional.

All I can tell you is to check the Forms messages in the lower left-hand corner as you test your programs. The messages are usually small, and therefore easily overlooked, but they are your best source of information if your splash screen doesn't appear quite right.

So along with the admonition to save, save, save! let me add, check your syntax!


Building a Timer

Are you ready for the timer part? Let's build a form timer that will control how long your splash screen will display. This is just another bit of PL/SQL code that you'll add right where you left off:

graphics/13fig65.gif

Good! Just a couple more steps and we'll test the thing. As you've probably imagined, we now have a trigger that will fire, but we need something to recognize the firing, and then do something about it. Those are our next two, and last, steps for the splash screen.

What we have to do is create another trigger that will go off when our timer trigger fires, and then, within our new trigger, tell it where to go next. So here's what we have to do:

  1. Go back to Object Navigator.

  2. Click on Triggers .

  3. Click the green plus sign to create a new trigger.

  4. When the box opens, select WHEN-TIMER-EXPIRED .

graphics/13fig66.jpg

graphics/13fig67.gif

graphics/13fig68.gif

OK, you're saying, but how does Forms know which is the first form to display when the user starts the application? This is incredibly low-tech: It's just the first one in the data block list , so make sure your splash block is first! (To change the sequence, you can just drag and drop if necessary. But this is the only low-tech part of this process, so don't get too comfortable!)

Also make sure that all the subordinate items are where they belong. When working on very large systems, it's easy to get out of sync and create things in the wrong place, so double-check your work.

Let's test. The first time you compile, you'll probably get this message:

graphics/13fig69.gif

This usually means that when you placed the item on the canvas, it was outside the borders. Positioning can be tricky, so just go back to your splash canvas and move the item block or image block until you get it in the right place:

graphics/13fig70.gif

Now test your work: Select Program Run Form Client/Server and log on to any database:

graphics/13fig71.gif

If everything is now working, your splash screen will appear, followed in five seconds by your main screen:

graphics/13fig72.gif

graphics/13fig73.gif

Since nothing is active yet, just click on the upper right X to get back to Object Navigator. Congratulations! Let's move on and make this thing come to life.



Guerrilla Oracle
Guerrilla Oracle: The Succinct Windows Perspective
ISBN: 0201750775
EAN: 2147483647
Year: 2003
Pages: 84

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net