home *** CD-ROM | disk | FTP | other *** search
-
- 2/10/92
-
- SPLASHSCREEN DEMO
-
- Files: Splash.pas - splashscreen unit source
- Splash.res - splashscreen bitmap resource
- Zwindow.pas - generic demo program
- Zilch.res -resource file for Zwindow.pas
- Splash.txt - this file
-
- This small project grew out of looking at the TPW bitmap that
- pops up every time you start the program. It is my understanding
- that Object Graphics has a method that creates this type of splash-
- screen, but rather than buy a library to accomplish this, I hacked
- around until I came up with something that worked. The result is
- the unit contained in SPLASH.PAS, which pops up a borderless
- bitmap window for ten seconds when your program starts. The
- window is modeless to the extent that it does not halt tasks in
- other currently executing programs, but greys out the parent
- program and does not allow the user to close it for the ten
- seconds it is onscreen. If the user clicked on the greyed parent
- program, he could actually access it while the splashscreen is
- visible, but the fact that the parent program appears inactive
- would discourage most users from doing so. This is probably
- not very memory efficient(as a sizable bitmap resource has
- to be loaded into memory every time the parent program
- executes) but it is quite slick and professional looking and is
- ideal for a shareware announcement. I have to mention that it
- drives me crazy that some shareware programmers use timed
- system modal dialog boxes that bring ALL Windows processes
- to a halt while their announcement displays. A few times I have
- loaded these programs while downloading remote data or in the
- midst of DDE processes and have lost data (it doesn't exactly
- make me want to run for my checkbook and register their programs).
- I think this splashscreen method is much more considerate of your
- end user.
-
- ABOUT ZWINDOW.PAS
- This is a generic TWindow descendent that does nothing except display the
- splashscreen. It has a menu with an exit command and an about dialog. I
- included this program as a demo of how to add the splashscreen object to
- your existing programs. Since the splashscreen is a parentless popup
- window, the only way you can keep it from being overlapped by the parent
- window is to call it in between the TApplication.Init and .Run methods :
-
- var
- ZApp : ZilchApp;
-
- begin
- ZApp.Init('ZilchApp');
- {this inits the splashscreen object}
- Application^.MakeWindow(New(PPicWindow, Init(nil, ws_Popup
- or ws_visible and not ws_OverlappedWindow)));
- ZApp.Run;
- ZApp.Done;
- end.
- The NIL statement in the splashscreen's init method registers it as a
- parentless popup that technically is owned by the application but can act
- independently of it. A normal child window would have a "@self" statement
- in that position. The _ws parameters define it's behavior and appearance
- and are described (in not very much detail) in the TPW Programmer's Ref.
- Note: I have tried dozens of combinations of _ws parameters and
- this was the only one that gave me the desired results. I hope some of you
- will fool around with this a little more- if you come up with other settings
- that work, please let me know.
- Other than this init statement, all you have to do to use the splashscreen
- in your program is to add it to your USES clause.
-
- ABOUT SPLASH.PAS
-
- {TPicWindow}
- TPicWindow.Init(AParent : PWindowsObject; AStyle : LongInt);
- Begin
- TWindow.Init(AParent,'');
- with Attr do
- begin
- Style := AStyle;
- X := 110; Y := 100; W := 390; H := 255;
- end;
- hOpenBmp := LoadBitmap(HInstance,id_OpenBmp);
- End;
-
- The TpicWindow constructor contains other parmeters that affect
- it's appearance. Using the AStyle:LongInt parameter allows you
- to access a child window's ws_style field to change it's width, height,
- (W,H) and the location at which it will open(X,Y). When you change
- the bitmap resource, be sure to change W and H to the dimensions
- of the new bitmap. The final statement loads the bitmap itself.
-
-
- {WM_Timer}
- procedure TpicWindow.WMTimer;
- Begin
- DeleteObject(hOpenBmp);
- KillTimer(hWindow, timer_ID);
- TWindow.CloseWindow;
- End;
-
- TPicWindow initializes a timer in it's Setup Window method:
-
- SetTimer(hWindow, timer_ID, 10000, nil);
- The third parameter( 10000 ) represents 10000 milleseconds, roughly 10
- seconds. By using this statement, you can execute a function when
- Windows returns a WM_Timer message to the window( hWindow) at
- the interval (10000) stated in SetTimer. Here, it closes TPicWindow,
- deletes the bitmap resource and and kills the timer itself (The timer is
- a global resource that will continue to take up memory if not deleted):
-
- Paint
- The paint method is an abbreviated version of the one contained in
- TWindow that can display bitmaps of up to 16 colors. A 256 color
- bitmap would not display properly here because of the lack of a
- palette handling method.
-
- Changing the Bitmap-this must be done on the .res file itself with
- a resource editor. If you rename the resource, you also have to
- change the id_bitmap statement.
-
- Note : The GetWindowClass and GetClassName functions are
- included for compatibility with the Windows MDI interface. They
- are not needed for non-MDI apps like the sample program.
-
- Enjoy
-
- Scott Hanrahan[70144,3033]
-
- P.S. -to give credit where due, I would like to mention two books that
- have been a great help to me in this and other projects: Turbo Pascal
- for Windows 3.0 Programming by Tom Swan, and Programming
- Windows by Charles Petzold
-
-