home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-02-24 | 4.4 KB | 138 lines |
-
- /* Copyright (C) Microsoft Corporation, 1996-1998. All rights reserved.
-
- This source code is intended only as a supplement to Microsoft
- Visual J++ 6.0. See this product's on-line documentation for detailed
- information regarding Microsoft code samples.
-
- */
-
- package splash;
- import wfc.ui.*;
- import wfc.core.*;
- /**Defines a functionless form that lets the user know the application has started
- */
- public final class SplashScreen extends Form implements ISplashable
- {
- /**takes the form for which it is supposed to open
- */
- public SplashScreen(Form pop)
- {
- //define some reasonable defaults
- initForm();
- //add an event handler to the creating form's onCreate Event (called from the win32 createWindowEx call)
- pop.addOnCreate(popCreate);
- try
- {
- ((ISplashable)pop).initSplash(this);
- }
- //a form needn't implement ISplashable to call this splashScreen
- catch(ClassCastException e)
- {
- //finish the default SplashScreen
- initSplash(this);
- }
- show();
- update();
- bringToFront();
- }
- public void pop_create(Object source, CreateEvent event)
- {
- Form pop = (Form)source;
- dispose();
- }
- //put the default picturebox and label on the class level so they can be accessed by forms using SplashScreen's default implementation
- protected PictureBox splashPicture = new PictureBox();
- protected Label splashLabel = new Label();
- //create an event handler for the parent's create event
- CreateEventHandler popCreate = new CreateEventHandler(this.pop_create);
- Container components = new Container();
-
- private void initForm()
- {
- this.setAnchor(ControlAnchor.NONE);
- this.setBackColor(new Color(255, 240, 240));
- this.setCursor(Cursor.WAIT);
- this.setLocation(new Point(200, 150));
- this.setSize(new Point(406, 295));
- this.setTabIndex(-1);
- this.setTabStop(false);
- this.setText("");
- this.setAutoScaleBaseSize(16);
- this.setBorderStyle(FormBorderStyle.FIXED_TOOLWINDOW);
- this.setClientSize(new Point(404, 293));
- this.setControlBox(false);
- this.setMaxButton(false);
- this.setMinButton(false);
- this.setShowInTaskbar(false);
- }
- /**Returns a handle to the pictureBox added in the default initSplash
- * must be called after SplashScreen.initSplash(SplashScreen)
- */
- public PictureBox getSplashPicture()
- {
- return splashPicture;
- }
- /**Replaces the pictureBox in the default initSplash with a new one
- * must be called before SplashScreen.initSplash(SplashScreen)
- */
- public void setSplashPicture(PictureBox splashPicture)
- {
- this.splashPicture = splashPicture;
- }
- /**Replaces the picture in the PictureBox with the picture in the path given
- */
- public void setSplashPicture(String imageFilePath) throws wfc.io.IOException
- {
- setSplashPicture(new Bitmap(imageFilePath));
- }
- /**Replaces the picture in the PictureBox with the Image object passed in
- * Resizes the PictureBox and form to accomodate
- */
- public void setSplashPicture(Image image)
- {
- Point size = image.getSize();
- splashPicture.setSize(size);
- setSize(size.x+60, size.y+150);
- }
- /**Returns a handle to the Label added in the default initSplash
- * must be called after SplashScreen.initSplash(SplashScreen)
- */
- public Label getSplashLabel()
- {
- return splashLabel;
- }
- /**replaces the pictureBox in the default initSplash with a new one
- * must be called before SplashScreen.initSplash(SplashScreen)
- */
- public void setSplashLabel(Label splashLabel)
- {
- this.splashLabel = splashLabel;
- }
- public void initSplash(SplashScreen splash)
- {
- PictureBox splashPicture = splash.splashPicture;
- Label splashLabel = splash.splashLabel;
- splashPicture.setLocation(new Point(30, 10));
- splashPicture.setSize(new Point(350, 172));
- splashPicture.setAnchor(ControlAnchor.TOPLEFT);
- try
- {
- //the Bitmap constructor has to take an absolute pathname, or a path from the folder in which the project is run
- splashPicture.setImage(new Bitmap("SplashScreen.gif"));
- }
- catch(wfc.io.IOException e){}
- splashLabel.setBackColor(Color.WHITE);
- splashLabel.setFont(new Font("MS Sans Serif", -30));
- splashLabel.setForeColor(new Color(128, 0, 128));
- splashLabel.setLocation(new Point(40, 210));
- splashLabel.setAnchor(ControlAnchor.BOTTOM);
- splashLabel.setSize(new Point(340, 40));
- splashLabel.setText("Made with Visual J++ 6.0");
- splashLabel.setTabIndex(2);
- splash.setNewControls(new Control[] {
- splashLabel,
- splashPicture});
- }
- }
-